You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by mrblobby <si...@hotmail.com> on 2011/01/14 13:28:49 UTC

Re: multiple feedback panels in same page

This does not work for me:

        final Form<String> form = new Form<String>("form");

        ComponentFeedbackMessageFilter filter = new
ComponentFeedbackMessageFilter(form);

        FeedbackPanel feedback = new FeedbackPanel("feedback", filter);
        feedback.setEscapeModelStrings(false);
        add(feedback);

None of the field level validation messages of the form go into this
feedback panel - which seems like a  bug.

I could create a feedback panel for every field - that works fine, but this
is 
a) too much work
b) you lose the errors on a long form - you need them at the top of the form
as well.

So I dont see why anyone would add a feedback panel to a form if it doesnt
actually catch any of the field validation.  Or are you supposed to write
some code on each field, catch this, and manually write to the forms
feedback panel using form.info(xx)?

If I use ContainerFeedbackMessageFilter then I get the feedback messages in
all my feedback panels - including my global one for the separate global
login form which is also pants.

Any ideas how to have 2 separate feedbacks for 2 separate forms, plus a
global one for anything outside this?


-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/multiple-feedback-panels-in-same-page-tp1886384p3217563.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: multiple feedback panels in same page

Posted by Arjun Dhar <dh...@yahoo.com>.
Hey i think this is documented, thats who I got to know.

Basically a 2 step process. You create a Behavior like:

/**
 * This class defines a behavior so that in Feedback (on validation errors)
individual
 * fields can be marked by the markup provided by the {@link
this#getErrorMarkup()}
 * @author Arjun Dhar
 *
 * @param <T>
 */
public class MarkErrorFieldBehavior<T> extends AbstractBehavior {
	private static final long serialVersionUID = 1L;

	@SuppressWarnings("unchecked")
	@Override
	public void onRendered(Component component) {
		FormComponent<T> fc = (FormComponent<T>) component;
		if (!fc.isValid()) {
			Response response = component.getResponse();
			response.write(getErrorMarkup());
		}
	}
	
	/**
	 * Provide HTML markup to mark the error field<br/>
	 * Example: &lt;span style='color: red'&gt;*&lt;/span&gt;
	 * 
	 * @return
	 */
	protected String getErrorMarkup() {
		return "&nbsp;X";
	}
}

..and for your field all you have to do is ".add(new
MarkErrorFieldBehavior<Double>())" -- add the behavior to it.

In my case I'm happy with "X" appearing. Adapt it to put the field name or
whatever text you want!
-Arjun
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/multiple-feedback-panels-in-same-page-tp1886384p3217575.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org