Struts validation nested property

S

spb

I am not sure this got posted. Apologize if you got it 2 times.

Hi,
I am trying to validate a form which has 4 fields using Struts
validations. 2 properties are in the same form eg.
<nested:text property="loginEmail" />
while 2 are nested example:
<nested:text property="billContact.person.firstName" />

I need to validate them and if any fails I need to display the field
label in red.

I am able to do that for properties in the same form using:
<logic:messagesPresent property="loginPassword">
<div class="error">
</logic:messagesPresent>
<fmt:message key="lbl.form.createAccount.password" /><fmt:message
key="lbl.form.required" />
<logic:messagesPresent property="loginPassword">
</div>
</logic:messagesPresent>

but if I try the same with the nested ones it does not work. I tried
printing all the errors out on top using <html:errors /> and all 4
errors show up. This is what I have in my validation.xml:
<field property="loginPassword"
depends="required,twoFields,minlength,maxlength">
<msg name="required" key="err.common.isRequired"/>
<msg name="twoFields" key="error.twofields.notequal"/>
<arg0 key="err.lbl.password" />
<arg1 key="err.lbl.password2" />
<var>
<var-name>secondProperty</var-name>
<var-value>loginPasswordConfirm</var-value>
</var>
<arg1 name="minlength" key="${var:minlength}" resource="false"/>
<var><var-name>minlength</var-name><var-value>5</var-value></var>
<arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
<var><var-name>maxlength</var-name><var-value>50</var-value></var>
</field>
<field property="billContact.person.firstName"
depends="required,minlength,maxlength">
<msg name="required" key="err.common.isRequired"/>
<arg0 key="err.lbl.firstName" />
<arg1 name="minlength" key="${var:minlength}" resource="false"/>
<var><var-name>minlength</var-name><var-value>1</var-value></var>
<arg1 name="maxlength" key="${var:maxlength}" resource="false"/>
<var><var-name>maxlength</var-name><var-value>40</var-value></var>
</field>

Does the label property for nested properties work differently? Please
help, I need to get this working asap.

Thanks in advance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,089
Latest member
Ketologenic

Latest Threads

Top