Example usage for org.apache.wicket.markup.html.form Form getLocale

List of usage examples for org.apache.wicket.markup.html.form Form getLocale

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.form Form getLocale.

Prototype

public Locale getLocale() 

Source Link

Document

Gets the locale for this component.

Usage

From source file:jp.go.nict.langrid.management.web.view.page.language.component.form.validator.OtherLanguagePathValidator.java

License:Open Source License

public void validate(Form form) {
    String value = parent.getNoValidateOtherValue();
    if (value == null || value.equals("")) {
        form.error("Field 'Languages' is required.");
        return;//from  www.j  ava 2  s. co  m
    }
    String[] paths = value.split("[)],\\s*[(]");
    String[] messageCode = new String[paths.length];
    for (int i = 0; i < paths.length; i++) {
        messageCode[i] = paths[i];
    }
    int j = 0;
    for (String path : paths) {
        path = path.replaceAll("[)]$", "");
        path = path.replaceAll("^[(]", "");
        if (path.contains("<->")) {
            String[] codes = path.split("<->");
            if (codes.length > 2) {
                form.error(MessageManager.getMessage("OtherLanguagePathValidator.invalidPath", Locale.ENGLISH,
                        messageCode[j]));
            }
            for (String code : codes) {
                if (code.contains("->")) {
                    form.error(MessageManager.getMessage("OtherLanguagePathValidator.invalidPath",
                            Locale.ENGLISH, messageCode[j]));
                    break;
                }
                if (!InternalLanguageModel.containName(code, form.getLocale())
                        && !InternalLanguageModel.containCode(code)) {
                    form.error(MessageManager.getMessage("OtherLanguagePathValidator.invalidPath",
                            Locale.ENGLISH, code));
                }
            }
        } else if (path.contains("->")) {
            if (hasSimplexValueError(path, form.getLocale())) {
                form.error(MessageManager.getMessage("OtherLanguagePathValidator.invalidPath", Locale.ENGLISH,
                        messageCode[j]));
            }
        } else if (!InternalLanguageModel.containName(path, form.getLocale())
                && !InternalLanguageModel.containCode(path)) {
            form.error(MessageManager.getMessage("OtherLanguagePathValidator.invalidCode", Locale.ENGLISH,
                    messageCode[j]));
        }
        j++;
    }
}

From source file:jp.go.nict.langrid.management.web.view.page.language.resource.component.form.validator.AccessLimitValidator.java

License:Open Source License

public void validate(Form<?> form) {
    Set<Pair<Period, LimitType>> pls = new HashSet<Pair<Period, LimitType>>();
    Iterator it = repeatingView.iterator();
    while (it.hasNext()) {
        AccessLimitFieldPanel c = (AccessLimitFieldPanel) it.next();
        if (c.getCount().getInput() == null) {
            continue;
        }// ww  w.j  a  v  a  2 s .  c  o  m
        if (c.getCount().getInput().length() == 0) {
            continue;
        }
        LimitType lt = c.getType().getSelectedType();
        Period p = c.getPeriod().getSelectedPeriod();
        Pair<Period, LimitType> pair = Pair.create(p, lt);
        if (pls.contains(pair)) {
            form.error(MessageManager.getMessage("AccessLimitValidator", form.getLocale()));
            return;
        }
        pls.add(pair);
    }
}

From source file:jp.go.nict.langrid.management.web.view.page.user.component.form.validator.ChangePasswordFormValidator.java

License:Open Source License

public void validate(Form form) {
    Map<String, String> param = new HashMap<String, String>();
    if (oldPassword.getInput() == null || oldPassword.getInput().equals("")) {
        param.put("label", MessageManager.getMessage("oldPassword", form.getLocale()));
        oldPassword.error(MessageManager.getMessage("message.error.Required", param));
    }//from w ww  . ja  v  a  2s  .c  om
    if (newPassword.getInput() == null || newPassword.getInput().equals("")) {
        param.put("label", MessageManager.getMessage("password", form.getLocale()));
        newPassword.error(MessageManager.getMessage("message.error.Required", param));
    }
    if (confirm.getInput() == null || confirm.getInput().equals("")) {
        param.put("label", MessageManager.getMessage("confirm", form.getLocale()));
        confirm.error(MessageManager.getMessage("message.error.Required", param));
    }
    if (currentPassword != null && !currentPassword.equals(oldPassword.getInput())) {
        form.error(MessageManager.getMessage("message.error.password.Current", form.getLocale()));
    }
    if (!(newPassword.getInput().equals(confirm.getInput()))) {
        form.error(MessageManager.getMessage("PasswordConfirmValidator", form.getLocale()));
    }
}

From source file:jp.go.nict.langrid.management.web.view.page.user.component.form.validator.FormRegistUserValidator.java

License:Open Source License

public void validate(Form form) {
    if (!(password.getInput().equals(confirm.getInput()))) {
        form.error(MessageManager.getMessage("PasswordConfirmValidator", form.getLocale()));
    }//  w  w  w  .jav a2s .  co  m
}