aspose file tools*
The moose likes Struts and the fly likes Using attribute indexedListProperty in field tag in validation.xml Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Using attribute indexedListProperty in field tag in validation.xml" Watch "Using attribute indexedListProperty in field tag in validation.xml" New topic
Author

Using attribute indexedListProperty in field tag in validation.xml

Ramna Reddy
Ranch Hand

Joined: Aug 06, 2006
Posts: 96
Hi ranchers,
Iam using Validator framework, in one of the form,I have a List which contains Lastname,firstname etc, here I need to to validate these fields..

following is the example code....

<form name="XYZForm">
<field property="lastname" depends="required,mask" indexedListProperty="XYZListObject">

Its not working properly,what are the things to do to make it work properly using indexedListProperty...

Thanks in advance.
Ramna Reddy
Ranch Hand

Joined: Aug 06, 2006
Posts: 96
And I would like to know whether indexedListProperty is supported in struts or not?
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Yes, indexedListProperty is supported in Struts and I have used it successfully. If you specify indexedListProperty="XYZListObject", it is expected that the actual property name for the first element will be "XYZListObject[0].firstName", If that is not the case, the validation will not be performed. Be careful with case. Remember that if your getter is getXYZListObject, the property name used by Struts will be "xYZListObject" not "XYZListObject".


Merrill
Consultant, Sima Solutions
Ramna Reddy
Ranch Hand

Joined: Aug 06, 2006
Posts: 96
Hi Merrill,

Yes, indexedListProperty is supported in Struts and I have used it successfully. If you specify indexedListProperty="XYZListObject", it is expected that the actual property name for the first element will be "XYZListObject[0].firstName", If that is not the case, the validation will not be performed. Be careful with case. Remember that if your getter is getXYZListObject, the property name used by Struts will be "xYZListObject" not "XYZListObject".

can you please give an example code,or correct this to make it work,this is what iam using in validation.xml...

<form name="IPForm">
<field property="lastname" depends="required,mask" indexedListProperty="pListObject">
<arg0 key="lastname" />
<msg name="mask" key="errors.addpax.LastName.required"/>
<var>
<var-name>mask</var-name>
<var-value>^[a-zA-Z ,]*$</var-value>
</var>
</field>
</form>

Thanks in advance,
RR
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I wouldn't be able to tell is your code is correct or not without also seeing your ActionForm bean, the relevant portion of your struts-config.xml file, and the relevant portion of the JSP.

Here is code from a sample page that I have tested and can verify that it works.

struts-config.xml

validation.xml

testRating.jsp
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using attribute indexedListProperty in field tag in validation.xml