• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

intRange validations

 
Padmini Nagarajan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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'.
 
Padmini Nagarajan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic