Search in sources :

Example 1 with ItemTexts

use of cz.metacentrum.perun.webgui.model.ItemTexts in project perun by CESNET.

the class RegistrarFormItemGenerator method checkValueRegex.

protected boolean checkValueRegex() {
    if (item.getRegex() != null && !("".equals(item.getRegex()))) {
        // Compile and use regular expression
        RegExp regExp = RegExp.compile(item.getRegex());
        MatchResult matcher = regExp.exec(strValueBox.getValue());
        // equivalent to regExp.test(inputStr);
        boolean matchFound = (matcher != null);
        if (!matchFound) {
            String errorMessage = ApplicationMessages.INSTANCE.incorrectFormat();
            // does a custom message exist?
            ItemTexts it = item.getItemTexts(locale);
            if (it != null) {
                if (it.getErrorMessage() != null && !it.getErrorMessage().equals("")) {
                    errorMessage = it.getErrorMessage();
                }
            }
            statusCellWrapper.setWidget(new FormInputStatusWidget(errorMessage, Status.ERROR));
            return false;
        }
    }
    return true;
}
Also used : ItemTexts(cz.metacentrum.perun.webgui.model.ItemTexts) RegExp(com.google.gwt.regexp.shared.RegExp) MatchResult(com.google.gwt.regexp.shared.MatchResult)

Aggregations

MatchResult (com.google.gwt.regexp.shared.MatchResult)1 RegExp (com.google.gwt.regexp.shared.RegExp)1 ItemTexts (cz.metacentrum.perun.webgui.model.ItemTexts)1