Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error messages for array of radiobuttons

 
shah rah
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<logic:iterate id="mid" name="MQuesForm" property="Mcriteria" indexId="x">
<tr>
<bean efine id="theValue" value = '<%="MMessage.Mvalue."+x+"" %>'/>
<td><bean:message key="<%=theValue%>" bundle = "MMessage"/> </td>
<logic:iterate id="choice" name="MQuesForm" property="Mchoices" >
<td>
<html:radio property='<%="Mcriteria["+x+"]" %>' value="<%=choice.toString() %>"/>

</td>

</logic:iterate>
<td></td>
<td><html:errors property='<%="Mcriteria["+x+"]" %>' bundle = "MMessage"/></td>
</tr>
</logic:iterate>



<field property="Mcriteria" indexedListProperty= "Mcriteria" depends="required">
<msg name="required" key="errors.required" />

<arg0 key="Error.Mcriteria" />


</field>

form-property name="Mcriteria" type="java.lang.String[]" size = "7"

why does the error not appear when I miss clicking one of the radiobutton

[ February 28, 2007: Message edited by: shah rah ]
[ February 28, 2007: Message edited by: shah rah ]
 
shah rah
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bumping it up.. Just to see if anyone has done this type of validation before and can guide me..
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try adding the following to your form-property definition for Mcriteria:

Radio buttons don't submit a value if they're not checked. You therefore have to reset the value to null string so the required validation will recognize that nothing has been entered.

Also, just show the <html:errors /> tag once at the end and remove the property attribute. From what I understand, when you validate indexed properties, you only get one error message and it's a global one
[ March 01, 2007: Message edited by: Merrill Higginson ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic