Hi,

On Sat, Apr 27, 2013 at 11:29 PM, Taro Fukunaga <[email protected]>wrote:

> I have a FencedFeedbackPanel inside a form but when I try to display a
> message, the form closes and the message is displayed on the main page
> instead of in my form. The form is in turn inside a modal window (see
> hierarchy below). When I have invalid input, I want my form (and modal
> window) to stay open and the error message displayed on that form so that
> the user can correct it.
>

ModalWindow is an Ajax component so you need to use AjaxButton or
AjaxSubmitLink to submit the form inside it.
Otherwise the whole page is re-rendered and the modal is being "closed"
(i.e. it is not opened in the new page instance).

When there is an error in a validation the button's
#onError(AjaxRequestTarget) will be called and here you have to do:
target.add(feedbackPanel)


>
> public class MyForm extends Form {
>   public MyForm {
>     FencedFeedbackPanel feedbackPanel = new FencedFeedbackPanel(
> "myFeedbackPanel", this );
>     feedbackPanel.setOutputMarkupId( true );
>     add( feedbackPanel );
>     ...
>   }
> }
>
> I am also using a FormValidator and am adding it to my field for
> validation.
>
> public class MyForm extends Form {
>   public MyForm {
>    ...
>    final TextField<Integer> myInput = new TextField<Integer>( "myInput",
> new
> IModel<Integer>() {
>    add( new MyFormValidator( myInput ) );
>
> The code for MyFormValidator is similar to
> http://blog.armstrongconsulting.com/?p=40, except that I'm using a
> TextField<Integer> instead of a TextArea. Like the example, in my code I am
> just saying error() in the validator and am expecting it to display inside
> the form.
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <wicket:panel xmlns:wicket="http://wicket.apache.org";>
>   <div id="myPanel">
>     <form id="myForm" wicket:id="myForm">
>
>
>
> The Hierarchy is like this:
>
> MyPage
>   |
> MyModalWindow
>   |
> MyPanel
>   |
> MyForm
>   |
> Input Field
>
> I'm using Wicket 6.5
>
> Thank you.
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Form-not-displaying-messages-correctly-tp4658351.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-- 
Martin Grigorov
Wicket Training & Consulting
http://jWeekend.com <http://jweekend.com/>

Reply via email to