• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

doubt in using validwhen

 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i want to validate the input fields based on a certain condition.

My validation.xml goes like this,

<form name="logonForm" >
<field property="username" depends="validwhen,required" >
<arg key="logonForm.username"/>
<var>
<var-name>test</var-name>
<var-value> (page == 9) </var-value>
</var>
</field>

<field property="password" depends="validwhen,required,mask" >
<arg key="logonForm.password"/>
<var>
<var-name>test</var-name>
<var-value> (page == 9) </var-value>
</var>

<var>
<var-name>mask</var-name>
<var-value>^[0-9a-zA-Z]*$</var-value>
</var>
</field>
</form>

</formset>

if the first condition fails(validwhen), the second shouldn't happen. But in my case despite of passing value zero for page, i get my 2nd validation executed.

please tell me where i am making mistake
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ValidWhen is only available in Struts Version 1.2 and above. You had mentioned in another thread that you're using Struts 1.1, so unless you've upgraded, the validWhen rule isn't going to work at all.

Secondly, I don't believe that your statement:

if the first condition fails(validwhen), the second shouldn't happen.


is necessarily true. I've looked through the documentation and haven't found anything that says one way or the other. My understanding is that a required validation rule will apply no matter what, regardless of its position in the list of validation rules. As I said, though, I haven't found statements to prove or disprove this in the documentation. If your statement is based on something you read in the documentation, please give us the link.
[ September 07, 2007: Message edited by: Merrill Higginson ]
 
Run away! Run away! Here, take this tiny ad with you:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic