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

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

Introduction

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

Prototype

public final void error(String error, Map<String, Object> args) 

Source Link

Document

Registers an error feedback message for this component

Usage

From source file:ca.travelagency.customer.CustomerDuplicateValidator.java

License:Apache License

@Override
public void validate(Form<?> form) {
    Customer customer = (Customer) form.getModelObject();
    Date date = dateOfBirth.getConvertedInput();
    customer.setDateOfBirth(date);//from w w w  . j av  a 2 s . c o m
    boolean duplicated = customerService.duplicated(customer);
    if (duplicated) {
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put(LAST_NAME, customer.getLastName());
        parameters.put(FIRST_NAME, customer.getFirstName());
        parameters.put(PRIMARY_PHONE, customer.getPrimaryPhone());
        parameters.put(DATE_OF_BIRTH, DateUtils.formatDate(date));
        String error = form.getLocalizer().getString(KEY, form);
        form.error(error, parameters);
    }
}

From source file:org.apache.karaf.webconsole.karaf.feature.repository.AddRepositoryPage.java

License:Apache License

@SuppressWarnings({ "rawtypes", "unchecked", "serial" })
public AddRepositoryPage() {
    final IModel<Repository> model = new Model(new WicketRepository());

    final Form<Repository> form = new Form<Repository>("form", model);
    form.add(new AddRepositoryPanel("repository", model));
    form.add(new SubmitLink("submit") {
        @Override/*from ww w . j  a v  a2 s. co  m*/
        public void onSubmit() {
            URI uri = model.getObject().getURI();
            try {
                featuresService.addRepository(uri);
            } catch (Exception e) {
                Map<String, Object> map = new HashMap<String, Object>();
                map.put("uri", uri);
                form.error("Can not create repository " + e.getMessage(), map);
            }
        }
    });

    add(form);
}