Re: Indexed Property Validation on a String[]
If all the options are going to have the same name, then this should work logic:iterate id=anOption name=myFormBean property=options html:text name=anOption property=options size=2/ /logic:iterate Since each element is a String, the tag will just that instead of making a property call. I believe that validator may just then apply whatever validation you have set for options to every element of the array. In 1.1, you can use the indexed attribute to number the options, and be sure they go back to the same elements in the array or collection, if that's important. Should just be logic:iterate id=anOption name=myFormBean property=options html:text name=anOption property=options indexed=true/ /logic:iterate For an array, I believe that's all you might need. -T. [EMAIL PROTECTED] wrote: Hi: I have a form bean that contains an attribute defined as a String[]. public class MyFormBean { String[] options = new String[100]; public void setOptions(String[] options) { this.options = options; } public String[] getOptions() { return options; } } I want to be able to display all 100 options in a JSP using the iterate tag. Let's assume that my form bean is stored in the session scope under the attribute named myFormBean. logic:iterate id=anOption name=myFormBean property=options indexId=index html:text indexed=true name=anOption property='?' size=2/nbsp;nbsp; % if ( (index.intValue()+1) % 10 == 0 ) % br /logic:iterate What should be filled in for the property since anOption is a String? Next, I need to set up a field validation in validation.xml. From the following URL, http://home.earthlink.net/~dwinterfeldt/revision.html a suggestion is made to use the following: logic:iterate id=listElement name=registrationForm property=listElementList indexId=index html:textarea indexed=true name=listElement property=value cols=60 rows=8/br /logic:iterate field property=value indexedProperty=listElement indexedListProperty=listElementList depends=required arg0 key=registrationForm.paragraph.displayname/ /field So far, I have the following: field property=? indexedProperty=anOption indexedListProperty=options depends=required arg0 key=label.optionLabel/ /field What should be filled in for the property since anOption is a String? Any help that anyone can provide will be greatly appreciated! Thanks in advance. Michael -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- Ted Husted, Husted dot Com, Fairport NY US -- Developing Java Web Applications with Struts -- Tel: +1 585 737-3463 -- Web: http://husted.com/about/services -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Indexed Property Validation on a String[]
There is an example of this in the Validator example webapp in the type.jsp page in the nightly builds using an ArrayList, but I believe everything should work for an array too (or you could use java.util.Arrays to convert to a Collection if you need to). web/validator/WEB-INF/validation.xml -- field property=value indexedListProperty=nameList depends=required arg0 key=typeForm.nested.name.displayname/ /field web/validator/type.jsp nested:iterate property=nameList tr th align=left nbsp; /th td align=left nested:messagesPresent property=value br ul nested:messages id=error property=value libean:write name=error//li /nested:messages /ul /nested:messagesPresent nested:text property=value size=15 maxlength=15/ /td /tr /nested:iterate David --- Ted Husted [EMAIL PROTECTED] wrote: If all the options are going to have the same name, then this should work logic:iterate id=anOption name=myFormBean property=options html:text name=anOption property=options size=2/ /logic:iterate Since each element is a String, the tag will just that instead of making a property call. I believe that validator may just then apply whatever validation you have set for options to every element of the array. In 1.1, you can use the indexed attribute to number the options, and be sure they go back to the same elements in the array or collection, if that's important. Should just be logic:iterate id=anOption name=myFormBean property=options html:text name=anOption property=options indexed=true/ /logic:iterate For an array, I believe that's all you might need. -T. [EMAIL PROTECTED] wrote: Hi: I have a form bean that contains an attribute defined as a String[]. public class MyFormBean { String[] options = new String[100]; public void setOptions(String[] options) { this.options = options; } public String[] getOptions() { return options; } } I want to be able to display all 100 options in a JSP using the iterate tag. Let's assume that my form bean is stored in the session scope under the attribute named myFormBean. logic:iterate id=anOption name=myFormBean property=options indexId=index html:text indexed=true name=anOption property='?' size=2/nbsp;nbsp; % if ( (index.intValue()+1) % 10 == 0 ) % br /logic:iterate What should be filled in for the property since anOption is a String? Next, I need to set up a field validation in validation.xml. From the following URL, http://home.earthlink.net/~dwinterfeldt/revision.html a suggestion is made to use the following: logic:iterate id=listElement name=registrationForm property=listElementList indexId=index html:textarea indexed=true name=listElement property=value cols=60 rows=8/br /logic:iterate field property=value indexedProperty=listElement indexedListProperty=listElementList depends=required arg0 key=registrationForm.paragraph.displayname/ /field So far, I have the following: field property=? indexedProperty=anOption indexedListProperty=options depends=required arg0 key=label.optionLabel/ /field What should be filled in for the property since anOption is a String? Any help that anyone can provide will be greatly appreciated! Thanks in advance. Michael -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- Ted Husted, Husted dot Com, Fairport NY US -- Developing Java Web Applications with Struts -- Tel: +1 585 737-3463 -- Web: http://husted.com/about/services -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] __ Do You Yahoo!? LAUNCH - Your Yahoo! Music Experience http://launch.yahoo.com -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
FW: Indexed Property Validation on a String[]
-Original Message- From: Kashambuzi, Michael (C) Sent: Tuesday, June 04, 2002 9:41 AM To: 'Struts Users Mailing List' Subject: Indexed Property Validation on a String[] Hi: I have a form bean that contains an attribute defined as a String[]. public class MyFormBean { String[] options = new String[100]; public void setOptions(String[] options) { this.options = options; } public String[] getOptions() { return options; } } I want to be able to display all 100 options in a JSP using the iterate tag. Let's assume that my form bean is stored in the session scope under the attribute named myFormBean. logic:iterate id=anOption name=myFormBean property=options indexId=index html:text indexed=true name=anOption property='?' size=2/nbsp;nbsp; % if ( (index.intValue()+1) % 10 == 0 ) % br /logic:iterate What should be filled in for the property since anOption is a String? Next, I need to set up a field validation in validation.xml. From the following URL, http://home.earthlink.net/~dwinterfeldt/revision.html a suggestion is made to use the following: logic:iterate id=listElement name=registrationForm property=listElementList indexId=index html:textarea indexed=true name=listElement property=value cols=60 rows=8/br /logic:iterate field property=value indexedProperty=listElement indexedListProperty=listElementList depends=required arg0 key=registrationForm.paragraph.displayname/ /field So far, I have the following: field property=? indexedProperty=anOption indexedListProperty=options depends=required arg0 key=label.optionLabel/ /field What should be filled in for the property since anOption is a String? Any help that anyone can provide will be greatly appreciated! Thanks in advance. Michael -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]