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();
}
Aggregations