File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes error messages for array of radiobuttons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "error messages for array of radiobuttons" Watch "error messages for array of radiobuttons" New topic
Author

error messages for array of radiobuttons

shah rah
Ranch Hand

Joined: Jan 04, 2007
Posts: 124
<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

Joined: Jan 04, 2007
Posts: 124
Bumping it up.. Just to see if anyone has done this type of validation before and can guide me..
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
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 ]

Merrill
Consultant, Sima Solutions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: error messages for array of radiobuttons
 
Similar Threads
required validation on integer field not working
how to show/hide rows within a logic:iterate
message resource for value property in html:radio
change 'action' path dynamically inside JSP.
Cannot create iterator for this collection