Search in sources :

Example 1 with Company

use of com.liferay.portal.kernel.model.Company in project liferay-blade-samples by liferay.

the class CustomScreenNameValidator method getAUIValidatorJS.

/**
 * Returns the JavaScript function to validate the screen name client-side.
 *
 * @return the JavaScript function
 */
@Override
public String getAUIValidatorJS() {
    StringBuilder javascript = new StringBuilder();
    try {
        Company company = _companyLocalService.getCompanyByWebId(PropsUtil.get(PropsKeys.COMPANY_DEFAULT_WEB_ID));
        long companyId = company.getCompanyId();
        String[] reservedWords = _getReservedWords(companyId);
        javascript.append("function(val) { return !(");
        for (int i = 0; i < reservedWords.length; i++) {
            javascript.append("val.indexOf(\"" + reservedWords[i] + "\") !== -1");
            if ((reservedWords.length > 1) && (i < (reservedWords.length - 1))) {
                javascript.append(" || ");
            }
        }
        javascript.append(")}");
    } catch (PortalException pe) {
        _log.error(pe);
    }
    return javascript.toString();
}
Also used : Company(com.liferay.portal.kernel.model.Company) PortalException(com.liferay.portal.kernel.exception.PortalException)

Aggregations

PortalException (com.liferay.portal.kernel.exception.PortalException)1 Company (com.liferay.portal.kernel.model.Company)1