On Mon, Nov 26, 2012 at 4:50 AM, James Selvakumar <ja...@mcruncher.com>wrote:

> Martin,
>
> Thank you so much. I was exactly in the position where delta458 was and
> almost got through with it.
> After following your suggestions, the ValidationMsgBehavior looks like
> this:
>
> <pre>
> public class ValidationMsgBehavior extends Behavior
> {
>     @Override
>     public void onRendered(Component c)
>     {
>         FormComponent fc = (FormComponent) c;
>         if (!fc.isValid()) {
>             String error;
>             if (fc.hasFeedbackMessage()) {
>                 error =
> fc.getFeedbackMessages().first(FeedbackMessage.ERROR).toString();
>             } else {
>                 error = "Your input is invalid.";
>             }
>             fc.getResponse().write(
>                     "<div class=\"validationErrorMessage\">" + error +
> "</div>");
>         }
>     }
> }
> </pre>
>
>

> I'm using Wicket 6.3.0 and there is no "onRendered" method in Behavior.
> I should be using "afterRender(Component component)" now, right?
>

Right.


> That will make this code compatible with the latest wicket version.
>
>
> On Wed, Oct 17, 2012 at 3:07 PM, Martin Grigorov <mgrigo...@apache.org
> >wrote:
>
> > On Wed, Oct 17, 2012 at 8:22 AM, delta458 <delta...@hotmail.com> wrote:
> > > Hi Martin,
> > > thanks so much for the replies... almost done, some little questions
> > still
> > > there.. I got it working, could you verify that its right what I made?
> :)
> > >
> > > 1)
> > > *//Had Error: Wrong number of type arguments, required 2 - It works
> when
> > I
> > > do  IVisitor<Component,Void> ;-)
> >
> > Trust the compiler and follow his recommendations ;-)
> >
> > > public class ShinyFormVisitor implements
> > IVisitor<Component>,Serializable {*
> > >
> > >     Set visited = new HashSet();
> > >
> > >     public void component(final Component c, final IVisit<Void> visit
> > > /*[2]*/) {
> > >         if (!visited.contains(c)) {
> > >             visited.add(c);
> > >             c.add(new RequiredBorder());
> > >             c.add(new ValidationMsgBehavior());
> > >             c.add(new ErrorHighlightBehavior());
> > >         }
> > >     }
> > >
> > > ...
> > >
> > >     private class ValidationMsgBehavior extends Behavior {
> > >
> > >         public void onRendered(Component c) {
> > >             FormComponent fc = (FormComponent) c;
> > >             if (!fc.isValid()) {
> > >                 String error;
> > >                 if (fc.hasFeedbackMessage()) {
> > >                   * //Had error, now working with this.. thats right?
> > >                     error =
> > > fc.getFeedbackMessages().first().getLevelAsString();*
> >
> > fc.getFeedbackMessages().first(FeedbackMessage.LEVEL_ERROR).toString();
> >
> > Or you may use the default registered converter to transform it to
> > String. But this is more advanced and most probably you don't need it.
> >
> > >
> > >                 } else {
> > >                     error = "Your input is invalid.";
> > >                 }
> > >                 fc.getResponse().write(
> > >                         "<div class=\"validationMsg\">" + error +
> > "</div>");
> > >             }
> > >         }
> > >     }
> > > }
> > >
> > >
> > > 2) Do you know any good wicket tutorials/example where I can learn how
> to
> > > work with customized FeedbackMessages?
> >
> > The source code is the best. It is really simple.
> > Check
> >
> https://github.com/apache/wicket/blob/master/wicket-core/src/main/java/org/apache/wicket/markup/html/panel/FeedbackPanel.java
> >
> > >
> > > thanks..
> > >
> > >
> > >
> > >
> > > --
> > > View this message in context:
> >
> http://apache-wicket.1842946.n4.nabble.com/highlight-invalid-fields-with-custom-Validation-Framework-tp4652949p4653024.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
> >
> >
>
>
> --
> Thanks & regards
> James Selvakumar
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>

Reply via email to