List of usage examples for org.apache.wicket.feedback ExactLevelFeedbackMessageFilter ExactLevelFeedbackMessageFilter
public ExactLevelFeedbackMessageFilter(int level)
From source file:ar.edu.udc.cirtock.view.intranet.negocio.FormularioInsumo.java
License:Apache License
public FormularioInsumo(final PageParameters parameters) { super(parameters); add(new FeedbackPanel("feedbackErrors", new ExactLevelFeedbackMessageFilter(FeedbackMessage.ERROR))); formulario = new Form("formulario_insumo"); nombre = new RequiredTextField<String>("nombre", new Model()); nombre.add(new IValidator<String>() { @Override/*w w w . ja v a2 s . c om*/ public void validate(IValidatable<String> validatable) { String nombre = validatable.getValue().trim().toUpperCase(); if (!nombre.matches("^[\\w\\s]{3,20}$")) { ValidationError error = new ValidationError(); error.setMessage("El campo 'nombre' no es valido"); validatable.error(error); } } }); formulario.add(nombre); descripcion = new RequiredTextField<String>("descripcion", new Model()); descripcion.add(new IValidator<String>() { @Override public void validate(IValidatable<String> validatable) { String descripcion = validatable.getValue().trim().toUpperCase(); if (!descripcion.matches("^[A-Za-z ]{3,50}$")) { ValidationError error = new ValidationError(); error.setMessage("El campo 'descripcion' no es valido"); validatable.error(error); } } }); formulario.add(descripcion); cantidad = new NumberTextField<Integer>("cantidad", new Model()); cantidad.setType(Integer.class); cantidad.add(new IValidator<Integer>() { @Override public void validate(IValidatable<Integer> validatable) { Integer cantidad = validatable.getValue(); if (cantidad < 0) { ValidationError error = new ValidationError(); error.setMessage("El campo 'cantidad' no es valido"); validatable.error(error); } } }); formulario.add(cantidad); formulario.add(new Button("enviar") { /** * */ private static final long serialVersionUID = 1L; public void onSubmit() { String desc = (String) descripcion.getModelObject(); String nomb = (String) nombre.getModelObject(); Integer cant = cantidad.getModelObject(); Connection conn = null; try { conn = CirtockConnection.getConection("cirtock", "cirtock", "cirtock"); Insumo ins = new Insumo(); ins.setDescripcion(desc); ins.setNombre(nomb); ins.setCantidad(cant); ins.insert("", conn); } catch (CirtockException e) { System.out.println("Error al acceder a la base de datos"); } finally { try { conn.close(); } catch (SQLException e) { ; } } setResponsePage(InsumoPage.class); }; }); add(formulario); }
From source file:org.apache.openmeetings.AbstractWicketTester.java
License:Apache License
public static List<FeedbackMessage> getErrors(WicketTester tester) { return tester.getFeedbackMessages(new ExactLevelFeedbackMessageFilter(FeedbackMessage.ERROR)); }
From source file:org.wicketstuff.datetime.examples.bean.validation.BeanValidationPage.java
License:Apache License
public BeanValidationPage() { add(new Link<Void>("datesPage") { private static final long serialVersionUID = 1L; @Override//from w w w.j av a 2 s. c o m public void onClick() { setResponsePage(DatesPage.class); } }); add(new FeedbackPanel("feedbackErrors", new ExactLevelFeedbackMessageFilter(FeedbackMessage.ERROR))); Form<?> form = new Form<Void>("form") { private static final long serialVersionUID = 1L; @Override protected void onSubmit() { super.onSubmit(); info("Form successfully submitted!"); } }; add(form); form.add(new TextField<>("name", new PropertyModel<String>(this, "person.name")) .add(new PropertyValidator<>())); form.add(new TextField<>("phone", new PropertyModel<String>(this, "person.phone")) .add(new PropertyValidator<>())); form.add(new TextField<>("email", new PropertyModel<String>(this, "person.email")) .add(new PropertyValidator<>())); form.add(new DateTextField("birthdate", new PropertyModel<>(this, "person.birthdate"), new StyleDateConverter("S-", true)).add(new PropertyValidator<>())); form.add(new TextField<>("password", new PropertyModel<String>(this, "person.password")) .add(new PropertyValidator<>())); add(new FeedbackPanel("feedbackSuccess", new ExactLevelFeedbackMessageFilter(FeedbackMessage.INFO))); }