You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by John Armstrong <si...@siberian.org> on 2009/07/24 23:23:54 UTC

How to display validation error for a RadioGroup?

I am trying to put a nice little '*' next to the RadioGroup when the
user forgets to select an item and just having a bear of a time with
something so simple.

Somehow I've ended up with a wicket:enclosure in the form. I've
created my own RadioGroup class (PNCRadioGroup) that overrides
onComponentTag to do the visibility toggling and I have labels in my
object that enable/disable visibility on to get the enclosures to show
up in specific validation cases. Its not working well and there has
got to be an easier way... Any tips?

<p class="paragraph_style">
	<span style="line-height: 15px;" class="style_1">Do you have high speed </span>
       <span style="line-height: 15px;" class="style_2">internet</span>
      <span style="line-height: 15px;" class="style_1">?
        <wicket:enclosure>
           <span wicket:id="highspeedavailablegrouperror"
class="invalid" style="padding: 2px 5px;">*</span>
        </wicket:enclosure>   <br />
     </span>
     </p>
     <span wicket:id="doyouhavehighspeedgroup">
     <p class="paragraph_style">
         <span style="line-height: 15px;" class="style_1">
             <input wicket:id="Yes" type="radio" /> Yes<br /> </span>
             </p>
	     <p class="paragraph_style">
             <span style="line-height: 15px;" class="style_1">  <input
wicket:id="No" type="radio" /> No <br /> </span>
            </p>
          </span>
      </p>
....
....


John-

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


Re: How to display validation error for a RadioGroup?

Posted by John Armstrong <si...@siberian.org>.
My final solution was to just override isVisible() on the labels that
are in the enclosures rather then doing it in onComponentTag.

Label highspeedAvailableRadioGroupError = new
Label("highspeedavailablegrouperror", "*")  {
			  public boolean isVisible() {
				  SurveyForm theForm = (SurveyForm)this.getParent();
				
				  if(theForm.isSubmitted()){
					  return highspeedAvailableRadioGroup.hasErrorMessage();
				  } else return false;
			  }
			};

Seems to work well so far. When the page renders the label it checks
the radio group to see if there was an error for that group. If so my
little red-enclosed * pops up to bother the user.

John-

On Fri, Jul 24, 2009 at 2:23 PM, John Armstrong<si...@siberian.org> wrote:
> I am trying to put a nice little '*' next to the RadioGroup when the
> user forgets to select an item and just having a bear of a time with
> something so simple.
>
> Somehow I've ended up with a wicket:enclosure in the form. I've
> created my own RadioGroup class (PNCRadioGroup) that overrides
> onComponentTag to do the visibility toggling and I have labels in my
> object that enable/disable visibility on to get the enclosures to show
> up in specific validation cases. Its not working well and there has
> got to be an easier way... Any tips?
>
> <p class="paragraph_style">
>        <span style="line-height: 15px;" class="style_1">Do you have high speed </span>
>       <span style="line-height: 15px;" class="style_2">internet</span>
>      <span style="line-height: 15px;" class="style_1">?
>        <wicket:enclosure>
>           <span wicket:id="highspeedavailablegrouperror"
> class="invalid" style="padding: 2px 5px;">*</span>
>        </wicket:enclosure>   <br />
>     </span>
>     </p>
>     <span wicket:id="doyouhavehighspeedgroup">
>     <p class="paragraph_style">
>         <span style="line-height: 15px;" class="style_1">
>             <input wicket:id="Yes" type="radio" /> Yes<br /> </span>
>             </p>
>             <p class="paragraph_style">
>             <span style="line-height: 15px;" class="style_1">  <input
> wicket:id="No" type="radio" /> No <br /> </span>
>            </p>
>          </span>
>      </p>
> ....
> ....
>
>
> John-
>

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