You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Chuck Brinkman <ch...@gmail.com> on 2010/01/08 09:02:24 UTC

how to clear validation error

I have a form with a html submit button.  In java I wrote my own onSubmit to
handle the form processing.  In the form I have a firstName field that is
required.
            <li>
                          First Name:
              <span wicket:id="borderFirstName">
                <input type="text" wicket:id="firstName"></input>
              </span>
            </li>

        TextField firstName = new TextField("firstName");
        firstName.setRequired(true);
        form.add(
                new FormComponentFeedbackBorder("borderFirstName").add(
                        firstName ) );

All works great as long as the user input is valid.  If I attempt to submit
an empty firstName field I get the expected message in my FeedbackPanel and
my firstName text field gets the red asterisk.  I then add a valid firstName
and submit again.  The page remains showing the valid firstName input along
with the validation errors and onSubmit does not fire.  I must be doing
something wrong but can't figure it out.

Thanks for your help.

I'm using wicket 1.4.5, tomcat 6, java 1.6 and firefox 3.0.8 on fc9.

Re: how to clear validation error

Posted by Nikola Šaub <ni...@gmail.com>.
Man thanks so much for this! The SAME thing happened to me. I left
cleanupFeedbackMessages()
empty after extending WebSession. I almost went crazy figuringthis out ;). 
 

Chuck Brinkman-2 wrote:
> 
> The messages are kept in WebSession and WebSession has
> cleanupFeedbackMessages() but this is never called.
> 
> Got it.  The session I created had a empty cleanupFeedbackMessages()
> method.  Thanks for reading along.
> 
> On Fri, Jan 8, 2010 at 9:48 PM, Chuck Brinkman <ch...@gmail.com>
> wrote:
> 
>> I got the code for wicket 1.4.5 and stepped through to see what is
>> causing
>> the problem.  Form.anyFormComponentError checks all the components on the
>> form to see if 1) input is required and 2) is an error message exists for
>> the component.  It appears to me that once a message is set that it is
>> never
>> reset.  I don't see how this could be working for others and not working
>> for
>> me.  Any ideas?  Is there some setup or configuration I'm missing that
>> causes error messages to be cleared?
>>
>>
>> On Fri, Jan 8, 2010 at 10:51 AM, Chuck Brinkman
>> <ch...@gmail.com>wrote:
>>
>>> Thanks for your help but I don't understand.  I even got the source code
>>> for
>>> http://www.wicket-library.com/wicket-examples/signin/?wicket:bookmarkablePage=:org.apache.wicket.examples.signin.SignInand
>>> when I run this in my environment I have the same issue I have with my
>>> code.  Once I get a validation error onSubmit is never called even after
>>> the
>>> input error is fixed.  This works fine when running at
>>> www.wicket-library.com.  What should I do in the onError method to
>>> correct this situation?  Sorry to be so lame and thanks for your help.
>>>
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/how-to-clear-validation-error-tp27072529p28021934.html
Sent from the Wicket - User 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: how to clear validation error

Posted by Chuck Brinkman <ch...@gmail.com>.
The messages are kept in WebSession and WebSession has
cleanupFeedbackMessages() but this is never called.

Got it.  The session I created had a empty cleanupFeedbackMessages()
method.  Thanks for reading along.

On Fri, Jan 8, 2010 at 9:48 PM, Chuck Brinkman <ch...@gmail.com> wrote:

> I got the code for wicket 1.4.5 and stepped through to see what is causing
> the problem.  Form.anyFormComponentError checks all the components on the
> form to see if 1) input is required and 2) is an error message exists for
> the component.  It appears to me that once a message is set that it is never
> reset.  I don't see how this could be working for others and not working for
> me.  Any ideas?  Is there some setup or configuration I'm missing that
> causes error messages to be cleared?
>
>
> On Fri, Jan 8, 2010 at 10:51 AM, Chuck Brinkman <ch...@gmail.com>wrote:
>
>> Thanks for your help but I don't understand.  I even got the source code
>> for
>> http://www.wicket-library.com/wicket-examples/signin/?wicket:bookmarkablePage=:org.apache.wicket.examples.signin.SignInand when I run this in my environment I have the same issue I have with my
>> code.  Once I get a validation error onSubmit is never called even after the
>> input error is fixed.  This works fine when running at
>> www.wicket-library.com.  What should I do in the onError method to
>> correct this situation?  Sorry to be so lame and thanks for your help.
>>
>
>

Re: how to clear validation error

Posted by Chuck Brinkman <ch...@gmail.com>.
I got the code for wicket 1.4.5 and stepped through to see what is causing
the problem.  Form.anyFormComponentError checks all the components on the
form to see if 1) input is required and 2) is an error message exists for
the component.  It appears to me that once a message is set that it is never
reset.  I don't see how this could be working for others and not working for
me.  Any ideas?  Is there some setup or configuration I'm missing that
causes error messages to be cleared?

On Fri, Jan 8, 2010 at 10:51 AM, Chuck Brinkman <ch...@gmail.com> wrote:

> Thanks for your help but I don't understand.  I even got the source code
> for
> http://www.wicket-library.com/wicket-examples/signin/?wicket:bookmarkablePage=:org.apache.wicket.examples.signin.SignInand when I run this in my environment I have the same issue I have with my
> code.  Once I get a validation error onSubmit is never called even after the
> input error is fixed.  This works fine when running at
> www.wicket-library.com.  What should I do in the onError method to correct
> this situation?  Sorry to be so lame and thanks for your help.
>

Re: how to clear validation error

Posted by Chuck Brinkman <ch...@gmail.com>.
Thanks for your help but I don't understand.  I even got the source code for
http://www.wicket-library.com/wicket-examples/signin/?wicket:bookmarkablePage=:org.apache.wicket.examples.signin.SignInand
when I run this in my environment I have the same issue I have with my
code.  Once I get a validation error onSubmit is never called even after the
input error is fixed.  This works fine when running at
www.wicket-library.com.  What should I do in the onError method to correct
this situation?  Sorry to be so lame and thanks for your help.

Re: how to clear validation error

Posted by Martijn Dashorst <ma...@gmail.com>.
Override Form#onError

Martijn

On Fri, Jan 8, 2010 at 1:16 PM, Chuck Brinkman <ch...@gmail.com> wrote:
> I created a simple example.  Here is my html and java.  Once I get a
> validation error my onSubmit is not called.
>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
> http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html>
>    <head>
>        <title>Current Page</title>
>        <link rel="stylesheet" href="dis.css" type="text/css" />
>        <meta http-equiv="Content-Type"
>            content="text/html; charset=ISO-8859-1" />
>    </head>
>    <body>
>        <div id="myPage">
>            <div id="feedbackContent">
>                <span wicket:id="feedback" />
>            </div>
>            <form wicket:id="validateForm">
>                <ul>
>                    <li>
>                        First Name:
>                        <span wicket:id="borderFirstName"> <input
> type="text"
>                                wicket:id="firstName"></input> </span>
>                    </li>
>                </ul>
>                <input type="submit" value="Update" />
>            </form>
>        </div>
>        <!-- myPage -->
>    </body>
> </html>
>
>
> public class Validate extends WebPage {
>    private static final Logger log = Logger.getLogger(Validate.class);
>    private String firstName;
>
>    public Validate() {
>        super();
>        init();
>    }
>
>    private void init() {
>        DisSession session = null;
>        session = DisSession.get();
>        setFirstName(session.getUser().getFirstName());
>
>        setDefaultModel(new CompoundPropertyModel(this));
>
>        Form form = new Form("validateForm") {
>            DisSession session = null;
>
>            @Override
>            protected void onSubmit() {
>                log.info("onSubmit called!");
>            }
>        };
>        add(form);
>
>        TextField firstName = new TextField("firstName");
>        firstName.setRequired(true);
>        form.add(new FormComponentFeedbackBorder("borderFirstName")
>                .add(firstName));
>
>        FeedbackPanel fbp = new FeedbackPanel("feedback");
>        add(fbp);
>
>    }
>
>    public String getFirstName() {
>        return firstName;
>    }
>
>    public void setFirstName(String firstName) {
>        this.firstName = firstName;
>    }
>
> }
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.4 increases type safety for web applications
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.4.4

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


Re: how to clear validation error

Posted by Chuck Brinkman <ch...@gmail.com>.
I created a simple example.  Here is my html and java.  Once I get a
validation error my onSubmit is not called.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title>Current Page</title>
        <link rel="stylesheet" href="dis.css" type="text/css" />
        <meta http-equiv="Content-Type"
            content="text/html; charset=ISO-8859-1" />
    </head>
    <body>
        <div id="myPage">
            <div id="feedbackContent">
                <span wicket:id="feedback" />
            </div>
            <form wicket:id="validateForm">
                <ul>
                    <li>
                        First Name:
                        <span wicket:id="borderFirstName"> <input
type="text"
                                wicket:id="firstName"></input> </span>
                    </li>
                </ul>
                <input type="submit" value="Update" />
            </form>
        </div>
        <!-- myPage -->
    </body>
</html>


public class Validate extends WebPage {
    private static final Logger log = Logger.getLogger(Validate.class);
    private String firstName;

    public Validate() {
        super();
        init();
    }

    private void init() {
        DisSession session = null;
        session = DisSession.get();
        setFirstName(session.getUser().getFirstName());

        setDefaultModel(new CompoundPropertyModel(this));

        Form form = new Form("validateForm") {
            DisSession session = null;

            @Override
            protected void onSubmit() {
                log.info("onSubmit called!");
            }
        };
        add(form);

        TextField firstName = new TextField("firstName");
        firstName.setRequired(true);
        form.add(new FormComponentFeedbackBorder("borderFirstName")
                .add(firstName));

        FeedbackPanel fbp = new FeedbackPanel("feedback");
        add(fbp);

    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

}

Re: how to clear validation error

Posted by Chuck Brinkman <ch...@gmail.com>.
maybe i left out too much code...

        <form wicket:id="currentUserPanelForm">
          <ul>
            <li>
            <span wicket:id="feedback"></span>
            </li>
        .....more html omitted

          </ul>
          <input type="submit" value="Update" />
        </form>

or am I still missing something?

On Fri, Jan 8, 2010 at 3:10 AM, Bodis, Jerome <bo...@uni-mainz.de> wrote:

> Shouldn't the FeedbackPanel be a child of the forms panel, instead of the
> form itself ? (don't know exactly = Your way the feedbackpanel gets
> submitted too)
>
> Jérôme
>
> -----Original Message-----
> From: Chuck Brinkman [mailto:chasb1957@gmail.com]
> Sent: Friday, January 08, 2010 9:02 AM
> To: users@wicket.apache.org
> Subject: how to clear validation error
>
> I have a form with a html submit button.  In java I wrote my own onSubmit
> to
> handle the form processing.  In the form I have a firstName field that is
> required.
>            <li>
>                          First Name:
>              <span wicket:id="borderFirstName">
>                <input type="text" wicket:id="firstName"></input>
>              </span>
>            </li>
>
>        TextField firstName = new TextField("firstName");
>        firstName.setRequired(true);
>        form.add(
>                new FormComponentFeedbackBorder("borderFirstName").add(
>                        firstName ) );
>
> All works great as long as the user input is valid.  If I attempt to submit
> an empty firstName field I get the expected message in my FeedbackPanel and
> my firstName text field gets the red asterisk.  I then add a valid
> firstName
> and submit again.  The page remains showing the valid firstName input along
> with the validation errors and onSubmit does not fire.  I must be doing
> something wrong but can't figure it out.
>
> Thanks for your help.
>
> I'm using wicket 1.4.5, tomcat 6, java 1.6 and firefox 3.0.8 on fc9.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: how to clear validation error

Posted by "Bodis, Jerome" <bo...@uni-mainz.de>.
Shouldn't the FeedbackPanel be a child of the forms panel, instead of the form itself ? (don't know exactly = Your way the feedbackpanel gets submitted too)

Jérôme

-----Original Message-----
From: Chuck Brinkman [mailto:chasb1957@gmail.com] 
Sent: Friday, January 08, 2010 9:02 AM
To: users@wicket.apache.org
Subject: how to clear validation error

I have a form with a html submit button.  In java I wrote my own onSubmit to
handle the form processing.  In the form I have a firstName field that is
required.
            <li>
                          First Name:
              <span wicket:id="borderFirstName">
                <input type="text" wicket:id="firstName"></input>
              </span>
            </li>

        TextField firstName = new TextField("firstName");
        firstName.setRequired(true);
        form.add(
                new FormComponentFeedbackBorder("borderFirstName").add(
                        firstName ) );

All works great as long as the user input is valid.  If I attempt to submit
an empty firstName field I get the expected message in my FeedbackPanel and
my firstName text field gets the red asterisk.  I then add a valid firstName
and submit again.  The page remains showing the valid firstName input along
with the validation errors and onSubmit does not fire.  I must be doing
something wrong but can't figure it out.

Thanks for your help.

I'm using wicket 1.4.5, tomcat 6, java 1.6 and firefox 3.0.8 on fc9.

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