On Mon, Oct 15, 2012 at 4:58 PM, delta458 <delta...@hotmail.com> wrote:
> I used the ShinyFormVisitor principle as described in the pdf: and I get
> following errors(in bold):
>
> public class ShinyFormVisitor implements IVisitor, Serializable {
>
>     Set visited = new HashSet();
>
>     public Object component(Component c) {
>         if (!visited.contains(c)) {
>             visited.add(c);
>             c.setComponentBorder(new RequiredBorder());

Since RequiredBorder is a behavior, you can just #add() it.

>             c.add(new ValidationMsgBehavior());
>             c.add(new ErrorHighlightBehavior());
>         }
> *//CONTINUE_TRAVERSAL could not be found*
>         return *IVisitor.CONTINUE_TRAVERSAL*;

IVisitor has been improved for Wicket 1.5.0.
Example:
new IVisitor<Component, Void>()
                {
                        public void component(final Component component, final 
IVisit<Void> visit)
                        {
                                add(component);
                                visit.dontGoDeeper();
                        }
                });

I.e. you need to use visit#XYZ methods to stop the visitor. Don't call
anything and it will continue.

>     }
>
>     private class RequiredBorder extends BorderBehavior {
>
>         public void renderAfter(Component component) {
>             FormComponent fc = (FormComponent) component;
>             if (fc.isRequired()) {
>                 super.afterRender(component);
>             }
>         }
>     }
>
> *//AbstractBehaviour could not be found*
>     private class ValidationMsgBehavior extends *AbstractBehavior* {

AbstractBehavior is renamed to 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();
>                 } else {
>                     error = "Your input is invalid.";
>                 }
>                 fc.getResponse().write(
>                         "<div class=\"validationMsg\">" + error + "</div>");
>             }
>         }
>     }
>
> *//AbstractBehaviour could not be found*
>     private class ErrorHighlightBehavior extends *AbstractBehavior* {
>
>         public void onComponentTag(Component c, ComponentTag tag) {
>             FormComponent fc = (FormComponent) c;
>             if (!fc.isValid()) {
>                 tag.put("class", "error");
>             }
>         }
>     }
> }

You face all these problems because you migrate code from version X to
version X + Y, where Y is > 1, i.e. you need to read the migration
guides for all the steps.
Or just ask here and we will try to help you :-)

>
>
>
> --
> View this message in context: 
> http://apache-wicket.1842946.n4.nabble.com/highlight-invalid-fields-with-custom-Validation-Framework-tp4652949p4652978.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

Reply via email to