Jonathan Locke wrote:
> 
> 

> ComponentFeedbackPanel will only ever show error messages reported by the
> given component:
> 
>       public boolean accept(FeedbackMessage message)
>       {
>               return component == message.getReporter();
>       }
> 

> If you want to show validation errors for a form when there are multiple
> forms on the page, you're going to need to create your own subclass of
> FeedbackPanel (or your own IFeedback implementation) which filters so that
> it only shows messages reported by the given form.  More like:
> 

>        Form form;
> 
>       public boolean accept(FeedbackMessage message)
>       {
>               return message.getReporter() == form || isChild(form,
> message.getReporter());
>       }
> 

> would be nice to add isChildOf to MarkupContainer so this could be
> form.isChild(message.getReporter()), but it's an easy method to write
> (just walk up the parent hierarchy looking for form).
> 
> A component that does this might make a nice wicket extension.  Something
> like FormFeedbackPanel(Form form).
> 
Thanks, Jonathan. In fact there is a contains() method that obviates the
need for isChild() or isChildOf(). Here's my implementation, it does exactly
what I need:
public class FormFeedbackPanel extends FeedbackPanel
{
        public FormFeedbackPanel(String id, final Form form)
        {
                super(id, new ComponentFeedbackMessageFilter(form)
                {
                        @Override
                        public boolean accept(FeedbackMessage message)
                        {
                                return message.getReporter() == form
                                        || form.contains(message.getReporter(), 
true);
                        }
                });
        }
}

-- 
View this message in context: 
http://www.nabble.com/ComponentFeedbackPanel-and-EqualPasswordInputValidator-tf3868087.html#a10974025
Sent from the Wicket - User mailing list archive at Nabble.com.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to