You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by droitbarg <dr...@gmail.com> on 2010/09/21 13:12:38 UTC

FeedbackPanel does not clean up after displaying error messages using Ajax

Hello everyone!

I am experiencing a problem whenever submiting a form using an
AjaxSubmitLink. I have tried using wicket from version 1.4.9 to 1.4.12
If the form fields are properly filled the first time( and validation
succeeds) my AjaxSubmitLink calls onSubmit and everything goes straight.
If any required field is missing the proper error message is displayed in
the feedback panel
But if I got an error message and I fill the required field in a second
round,  the error message keeps on coming.
After the first validation failure I always get calls to
AjaxSubmitLink.onError() even though the fields are properly filled.

Could anybody tell me what am I doing wrong?

Here is my code


In my home page I have the following:

HomePage.xml

                    <form wicket:id="mainform" >
                        <div wicket:id="feedbackPanel"/>
                        <div wicket:id="newClientPanel"/>

                    </form>
                    <div wicket:id="buttonsPanel"/>


newClientPanel.xml

<wicket:panel>
    <form wicket:id="newClient" >

        <table>
            <tr>
                <td><wicket:message
key="newclient.title">[newclient.title]</wicket:message></td>
            </tr>
            <tr>
                <td><wicket:message key="name">[name]</wicket:message></td>
            <td><input type="text" wicket:id="name" /></td>
            </tr>

            <tr>
                <td><wicket:message
key="surname">[surname]</wicket:message></td>
            <td><input type="text" wicket:id="surname" /></td>
            </tr>
            <tr>
                <td><wicket:message
key="phoneNumber">[phoneNumber]</wicket:message></td>
            <td><input type="text" wicket:id="phoneNumber" /></td>
            </tr>
            <tr>
                <td><wicket:message
key="email">[email]</wicket:message></td>
            <td><input type="text" wicket:id="email" /></td>
            </tr>

        </table>

    </form>
</wicket:panel>

newClientPanel.java

    private void addComponents() {
        clientForm = new Form<Client>("newClient");

        clientForm.setModel(new CompoundPropertyModel<Client>(client));
        clientForm.add(new RequiredTextField<String>("name"));
        clientForm.add(new RequiredTextField<String>("surname"));
        clientForm.add(new RequiredTextField<String>("phoneNumber"));
        clientForm.add(new
RequiredTextField<String>("email").add(EmailAddressValidator.getInstance()));
        add(clientForm);
    }


buttonsPanel.java


        saveLink = new AjaxSubmitLink("save", mainform) {

            @Override
            protected void onSubmit(AjaxRequestTarget target, Form<?> form)
{
                //Saving data here

            }

            @Override
            protected void onError(final AjaxRequestTarget target,  Form<?>
form) {
                super.onError(target, form);
                target.addComponent(getFeedBackPanel());

            }

        };
        add(saveLink);

 TIA

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/FeedbackPanel-does-not-clean-up-after-displaying-error-messages-using-Ajax-tp2548394p2548394.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: FeedbackPanel does not clean up after displaying error messages using Ajax

Posted by Wilhelmsen Tor Iver <To...@arrive.no>.
> Don't worry, we've all had those head <--> palm moments :)

PEBKAC. :)

Maybe a FindBugs plugin that checks that overridden methods always have a non-empty implementation? Even the Eclipse built-in test for empty blocks would help in some cases (except it allows a comment to satisfy the condition).

- Tor Iver

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


Re: FeedbackPanel does not clean up after displaying error messages using Ajax

Posted by Jeremy Thomerson <je...@wickettraining.com>.
On Wed, Sep 22, 2010 at 4:58 AM, droitbarg <dr...@gmail.com> wrote:

> I found the source of my problem.
> In the session I had this piece of code:
>
>  @Override
>    public void cleanupFeedbackMessages() {
>        //throw new UnsupportedOperationException("Not supported yet.");
>    }
>
> This was the reason the feedback panel never cleaned up.
>

Don't worry, we've all had those head <--> palm moments :)

-- 
Jeremy Thomerson
http://www.wickettraining.com

Re: FeedbackPanel does not clean up after displaying error messages using Ajax

Posted by droitbarg <dr...@gmail.com>.
I found the source of my problem.
In the session I had this piece of code:

  @Override
    public void cleanupFeedbackMessages() {
        //throw new UnsupportedOperationException("Not supported yet.");
    }

This was the reason the feedback panel never cleaned up.

Thanks for the help!
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/FeedbackPanel-does-not-clean-up-after-displaying-error-messages-using-Ajax-tp2548394p2550027.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: FeedbackPanel does not clean up after displaying error messages using Ajax

Posted by Alexander Morozov <al...@gmail.com>.
      saveLink = new AjaxSubmitLink("save", mainform) {

            @Override
            protected void onSubmit(AjaxRequestTarget target, Form<?> form)
{
                /* do not forget to refresh feedback panel on successful
submit */
                info("Request processed successfully!");
                target.addComponent(getFeedBackPanel());
            }

            @Override
            protected void onError(final AjaxRequestTarget target,  Form<?>
form) {
                super.onError(target, form);
                target.addComponent(getFeedBackPanel());           
            }

        };
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/FeedbackPanel-does-not-clean-up-after-displaying-error-messages-using-Ajax-tp2548394p2548537.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: FeedbackPanel does not clean up after displaying error messages using Ajax

Posted by droitbarg <dr...@gmail.com>.
I made a small mistake:

Where it says 
        add(new ButtonsPanel("buttonsPanel", detailPanel, feedbackPanel,
form)); 
it should be:

        add(new ButtonsPanel("buttonsPanel", detailPanel, feedbackPanel,
primaryform)); 
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/FeedbackPanel-does-not-clean-up-after-displaying-error-messages-using-Ajax-tp2548394p2548480.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: FeedbackPanel does not clean up after displaying error messages using Ajax

Posted by droitbarg <dr...@gmail.com>.
Alexander: thanks for your quick answer!
I have done as you said but I still get the same problem.

My HomePage.java code is:

    public HomePage(final PageParameters parameters) {
        getSession().setHomePage(this);

        Form form = new Form("primaryform");
        FeedbackPanel feedbackPanel = new FeedbackPanel("feedbackPanel");
        feedbackPanel.setOutputMarkupPlaceholderTag(true);
        form.add(feedbackPanel);

        DetailPanel detailPanel = new NewClientPanel("newClientPanel");
        form.add(detailPanel);
        add(new ButtonsPanel("buttonsPanel", detailPanel, feedbackPanel,
form));
        add(form);

        headerContributions();     
    }

I still get the error messages but they never go away
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/FeedbackPanel-does-not-clean-up-after-displaying-error-messages-using-Ajax-tp2548394p2548477.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: FeedbackPanel does not clean up after displaying error messages using Ajax

Posted by Alexander Morozov <al...@gmail.com>.
What about feedback markup ID ? Is it present on the page ? 
It seems that you forgot to invoke setOutputMarkupPlaceholderTag(true) on
FeedbackPanel instance.
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/FeedbackPanel-does-not-clean-up-after-displaying-error-messages-using-Ajax-tp2548394p2548415.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