You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Clay Lehman <cl...@medfusion.net> on 2007/09/25 15:56:20 UTC

Form Feedback

Hey everyone,

 

I am pretty new to Wicket, and I am having a hard time figuring out the
best way to provide feedback if a form's validation fails.

 

I want 2 things to be visible if there is a validation error: 

1)      list the validation error messages at the top of the form

2)      red stars by the Label of each input item that caused an error.

 

I have found examples using a FormComponentFeedbackBorder, but that just
appends a red start to the end of the input field (rather than the
label.  It looks like FormComponentFeedbackIndicator might do what I
need based on the javadocs, but I have not been able to find an example
using this, and I am having trouble getting it to work.

 

Does anybody have some advice on the best way to achieve this type of
form feedback?

 

Thanks!!

-Clay

 


Re: Form Feedback

Posted by Gerolf Seitz <ge...@gmail.com>.
you probably have to call FormComponentFeedbackIndicator#updateFeedback in
onSubmit and onError,
but i think overriding isVisibile is the the better approach.

maybe FCFI should override isVisible itself...

On 9/25/07, Clay Lehman <cl...@medfusion.net> wrote:
>
> Hey Gerolf,
>
> I used the following to do feedback as you suggested, but the red "*" is
> always visible, rather than just after an error, even on rendering the
> page before I do any submits.
>
> Here is the code I have in my Form's constructor:
>
>        RequiredTextField itemid = new
> RequiredTextField("itemid",Integer.class);
>
>        FormComponentFeedbackIndicator fd = new
> FormComponentFeedbackIndicator("itemidFeedback");
>        fd.setIndicatorFor(itemid);
>        add(itemid);
>        add(fd);
>
> And Here is the Code I have in the html file (inside the form):
>
>           <tr>
>             <td>ItemId:<span wicket:id="itemidFeedback"/></td>
>             <td><input type=text wicket:id="itemid"/></td>
>           </tr>
>
> On further investigation, I sublassed FormComponentFeedbackIndicator and
> overwrote the isVisible() method like this:
>
>         public boolean isVisible()
>         {
>             return
> Session.get().getFeedbackMessages().hasMessage(getFeedbackMessageFilter(
> ));
>         }
>
> With this change, the * shows up only when I would expect it to...
>
> Do you have any idea what would cause the default behavior not to work
> properly?
>
> This is all setup in a QuickStart project, using Java 1.4
>
> Thanks for any help.
>
> -Clay
>
> -----Original Message-----
> From: Gerolf Seitz [mailto:gerolf.seitz@gmail.com]
> Sent: Tuesday, September 25, 2007 11:31 AM
> To: users@wicket.apache.org
> Subject: Re: Form Feedback
>
> in your case (appending star to the label) i would do the following:
> // html
> <label wicket:id="inputLabel">[label]</label><span
> wicket:id="inputIndicator">*</span><input type="text"
> wicket:id="input"/>
>
> // java
> TextField input = new TextField("input", new Model(""));
> FormComponentFeedbackIndicator inputIndicator = new
> FormComponentFeedbackIndicator("inputIndicator");
> inputIndicator.setIndicatorFor(input);
>
> notice:
> the "*" between the span tags is not used as the actual output but
> rather
> for a preview if you open the .html file in a browser
>
> hth,
>   gerolf
>
> On 9/25/07, Clay Lehman <cl...@medfusion.net> wrote:
> >
> > Hey everyone,
> >
> >
> >
> > I am pretty new to Wicket, and I am having a hard time figuring out
> the
> > best way to provide feedback if a form's validation fails.
> >
> >
> >
> > I want 2 things to be visible if there is a validation error:
> >
> > 1)      list the validation error messages at the top of the form
> >
> > 2)      red stars by the Label of each input item that caused an
> error.
> >
> >
> >
> > I have found examples using a FormComponentFeedbackBorder, but that
> just
> > appends a red start to the end of the input field (rather than the
> > label.  It looks like FormComponentFeedbackIndicator might do what I
> > need based on the javadocs, but I have not been able to find an
> example
> > using this, and I am having trouble getting it to work.
> >
> >
> >
> > Does anybody have some advice on the best way to achieve this type of
> > form feedback?
> >
> >
> >
> > Thanks!!
> >
> > -Clay
> >
> >
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

RE: Form Feedback

Posted by Clay Lehman <cl...@medfusion.net>.
Hey Gerolf,

I used the following to do feedback as you suggested, but the red "*" is
always visible, rather than just after an error, even on rendering the
page before I do any submits.

Here is the code I have in my Form's constructor:

       RequiredTextField itemid = new
RequiredTextField("itemid",Integer.class);

       FormComponentFeedbackIndicator fd = new
FormComponentFeedbackIndicator("itemidFeedback");
       fd.setIndicatorFor(itemid);
       add(itemid);
       add(fd);

And Here is the Code I have in the html file (inside the form):

	  <tr>
	    <td>ItemId:<span wicket:id="itemidFeedback"/></td>
  	    <td><input type=text wicket:id="itemid"/></td>
  	  </tr>

On further investigation, I sublassed FormComponentFeedbackIndicator and
overwrote the isVisible() method like this:

        public boolean isVisible()
        {
            return
Session.get().getFeedbackMessages().hasMessage(getFeedbackMessageFilter(
));
        }

With this change, the * shows up only when I would expect it to...

Do you have any idea what would cause the default behavior not to work
properly?

This is all setup in a QuickStart project, using Java 1.4

Thanks for any help.

-Clay

-----Original Message-----
From: Gerolf Seitz [mailto:gerolf.seitz@gmail.com] 
Sent: Tuesday, September 25, 2007 11:31 AM
To: users@wicket.apache.org
Subject: Re: Form Feedback

in your case (appending star to the label) i would do the following:
// html
<label wicket:id="inputLabel">[label]</label><span
wicket:id="inputIndicator">*</span><input type="text"
wicket:id="input"/>

// java
TextField input = new TextField("input", new Model(""));
FormComponentFeedbackIndicator inputIndicator = new
FormComponentFeedbackIndicator("inputIndicator");
inputIndicator.setIndicatorFor(input);

notice:
the "*" between the span tags is not used as the actual output but
rather
for a preview if you open the .html file in a browser

hth,
  gerolf

On 9/25/07, Clay Lehman <cl...@medfusion.net> wrote:
>
> Hey everyone,
>
>
>
> I am pretty new to Wicket, and I am having a hard time figuring out
the
> best way to provide feedback if a form's validation fails.
>
>
>
> I want 2 things to be visible if there is a validation error:
>
> 1)      list the validation error messages at the top of the form
>
> 2)      red stars by the Label of each input item that caused an
error.
>
>
>
> I have found examples using a FormComponentFeedbackBorder, but that
just
> appends a red start to the end of the input field (rather than the
> label.  It looks like FormComponentFeedbackIndicator might do what I
> need based on the javadocs, but I have not been able to find an
example
> using this, and I am having trouble getting it to work.
>
>
>
> Does anybody have some advice on the best way to achieve this type of
> form feedback?
>
>
>
> Thanks!!
>
> -Clay
>
>
>
>

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


Re: Form Feedback

Posted by Gerolf Seitz <ge...@gmail.com>.
in your case (appending star to the label) i would do the following:
// html
<label wicket:id="inputLabel">[label]</label><span
wicket:id="inputIndicator">*</span><input type="text" wicket:id="input"/>

// java
TextField input = new TextField("input", new Model(""));
FormComponentFeedbackIndicator inputIndicator = new
FormComponentFeedbackIndicator("inputIndicator");
inputIndicator.setIndicatorFor(input);

notice:
the "*" between the span tags is not used as the actual output but rather
for a preview if you open the .html file in a browser

hth,
  gerolf

On 9/25/07, Clay Lehman <cl...@medfusion.net> wrote:
>
> Hey everyone,
>
>
>
> I am pretty new to Wicket, and I am having a hard time figuring out the
> best way to provide feedback if a form's validation fails.
>
>
>
> I want 2 things to be visible if there is a validation error:
>
> 1)      list the validation error messages at the top of the form
>
> 2)      red stars by the Label of each input item that caused an error.
>
>
>
> I have found examples using a FormComponentFeedbackBorder, but that just
> appends a red start to the end of the input field (rather than the
> label.  It looks like FormComponentFeedbackIndicator might do what I
> need based on the javadocs, but I have not been able to find an example
> using this, and I am having trouble getting it to work.
>
>
>
> Does anybody have some advice on the best way to achieve this type of
> form feedback?
>
>
>
> Thanks!!
>
> -Clay
>
>
>
>