Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using attribute indexedListProperty in field tag in validation.xml

 
Ramna Reddy
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And I would like to know whether indexedListProperty is supported in struts or not?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
 
Ramna Reddy
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic