Hi,

On Thu, Jan 26, 2012 at 10:36 PM, Wooldridge, Keith A
<keith.wooldri...@mantech.com> wrote:
> I'm trying to create a custom hibernate validator , based on bradhouse's 
> solution in this StackOverflow 
> thread<http://stackoverflow.com/questions/1972933/cross-field-validation-with-hibernate-validator-jsr-303>.
>   I'm passing in the field name that I would like the error message to be 
> associated with to addNode.  Unfortunately, my ComponentFeedbackMessageFilter 
> that is associated with the field in wicket does not know that the message 
> was directed to it.  I know wicket is getting the validation error from 
> Hibernate, because it shows up in my unfiltered feedback panel.
>
> Could it be that I'm adding the feedback messages from a Behavior instead of 
> from a FeedbackPanel directly?  The core of the Behavior, where the messages 
> get attached , is this:
>
> @Override
> public void afterRender(Component component) {
>      FormComponent<?> fc = (FormComponent<?>)component;
>      Response r = component.getResponse();
>
>      FeedbackMessages messages = fc.getSession().getFeedbackMessages();
>
>      if (messages.hasMessageFor(component)) {
>            r.write("<ul class=\"FeedbackStyle\">");
>            IFeedbackMessageFilter filter = new 
> ComponentFeedbackMessageFilter(component);
>            for (FeedbackMessage message : messages.messages(filter)) {

Try instead with:
 for (FeedbackMessage message : messages.messagesForComponent)

and then for each message:
message.markRendered();

>                  r.write("<li class=\"feedbackPanel");
>                  r.write(message.getLevelAsString().toUpperCase());
>                  r.write("\">");
>                  
> r.write(Strings.escapeMarkup(message.getMessage().toString()));
>                  r.write("</li>");
>            }
>            r.write("</ul>");
>      }
>      r.write("</span>");
> }
>
> Thanks,
>
> Keith Wooldridge
>
>



-- 
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