Search in sources :

Example 36 with RegExp

use of com.google.gwt.regexp.shared.RegExp 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

RegExp (com.google.gwt.regexp.shared.RegExp)36 MatchResult (com.google.gwt.regexp.shared.MatchResult)24 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)7 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)4 BasicOverlayType (cz.metacentrum.perun.webgui.model.BasicOverlayType)4 ArrayList (java.util.ArrayList)4 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)3 IsLoginAvailable (cz.metacentrum.perun.webgui.json.usersManager.IsLoginAvailable)3 SetLogin (cz.metacentrum.perun.webgui.json.usersManager.SetLogin)3 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)3 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)3 Test (org.junit.Test)3 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)2 GetEntityById (cz.metacentrum.perun.webgui.json.GetEntityById)2 CreatePassword (cz.metacentrum.perun.webgui.json.usersManager.CreatePassword)2 GenerateAccount (cz.metacentrum.perun.webgui.json.usersManager.GenerateAccount)2 PerunError (cz.metacentrum.perun.webgui.model.PerunError)2 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)2