File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes intRange validations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "intRange validations " Watch "intRange validations " New topic
Author

intRange validations

Padmini Nagarajan
Greenhorn

Joined: May 26, 2005
Posts: 5
Struts validator framework provides us with and intRange validation and can be used as below. My doubt here is , is there anyway that var-value can refer to a property instead of hard coded values like 10, 20 etc.
i.e I want to validate the range against another form property .

<field
property="integer"
depends="required,integer,intRange">
<arg0 key="typeForm.integer.displayname"/>
<arg1
name="intRange"
key="${var:min}"
resource="false"/>
<arg2
name="intRange"
key="${var:max}"
resource="false"/>
<var>
<var-name>min</var-name>
<var-value>10</var-value>
</var>
<var>
<var-name>max</var-name>
<var-value>20</var-value>
</var>
</field>
alan do
Ranch Hand

Joined: Apr 14, 2005
Posts: 354
you can use the 'validwhen' rule instead of intRange IF you are using struts 1.2.x. validwhen allows you to pass in other properties. see struts user guide on the apache site for examples of 'validwhen'.


-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
Padmini Nagarajan
Greenhorn

Joined: May 26, 2005
Posts: 5
Hi Alan,

Thanks for the reply. Tried validWhen rule and it works. But I still have a problem in displaying the error message.I am displaying a generic message like "Field XXX is not within the range,Please enter again" but now I need to display
a message like "Field XXX is not in the range ZZZ and YYY" Where ZZZ and YYY would again be dynamically generated values.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: intRange validations
 
Similar Threads
intrange validator message
Javascript error in range validation
Tags in validation.xml
Validation only greaterThan
Struts Validation not working