On Mon, Oct 15, 2012 at 11:17 PM, delta458 <delta...@hotmail.com> wrote: > Alright, I have something like this now: Problems/Errors are *bold* > * > //Here is a problem with the class: it says: ShinyFormVisitor is not > abstract and does not override abstract method component(Object,IVisit) in > IVisitor* > public class *ShinyFormVisitor* implements IVisitor, Serializable {
Make it : implements IVisitor<Component>, Serializable > > Set visited = new HashSet(); > > *//Is that ok now? with IVisitor for wicket 6.0?* > public void component(final Component c, final IVisit<Void> visit) { > if (!visited.contains(c)) { > visited.add(c); > c.add(new RequiredBorder()); > c.add(new ValidationMsgBehavior()); > c.add(new ErrorHighlightBehavior()); > } > visit.dontGoDeeper(); remove that ^^^. Let it go deeper > } > > private class RequiredBorder extends BorderBehavior { > > public void renderAfter(Component component) { > FormComponent fc = (FormComponent) component; > if (fc.isRequired()) { > super.afterRender(component); > } > } > } > > private class ValidationMsgBehavior extends Behavior { > > public void onRendered(Component c) { > FormComponent fc = (FormComponent) c; > if (!fc.isValid()) { > String error; > if (fc.hasFeedbackMessage()) { > *//getFeedbackMessage() could not be found* > error = > fc.*getFeedbackMessage()*.getMessage().toString(); fc.getFeedbackMessages().getFirst(Level.Error).toString (or something similar). Use an IDE to see the method signatures. > } else { > error = "Your input is invalid."; > } > fc.getResponse().write( > "<div class=\"validationMsg\">" + error + "</div>"); > } > } > } > > private class ErrorHighlightBehavior extends Behavior { > > @Override > public void onComponentTag(Component c, ComponentTag tag) { > FormComponent fc = (FormComponent) c; > if (!fc.isValid()) { > tag.put("class", "error"); > } > } > } > } > > > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/highlight-invalid-fields-with-custom-Validation-Framework-tp4652949p4652990.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org