Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Iam getting nulls in alert messages when using struts validator frame work

 
vamsi mummadi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
iam getting one problem while using java script validations from validator frame work. Iam giving int range validation for one field. while giving alert message when user entered value is not in range then iam getting nulls
in that message in the case of range values.
My code is like this
my form bean is
<form-bean name="reqOneForm" type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="voucher_no" type="java.lang.String"/>
<form-property name="req_date" type="java.lang.String"/>
<form-property name="req_name" type="java.lang.String"/>
<form-property name="count" type="java.lang.Integer"/>
<form-property name="req_by" type="java.lang.Integer"/>
</form-bean>


in validation.xml

<form name="reqOneForm">
<field property="count"
depends="required,integer,intRange">
<arg0 key="reqOneForm.count"/>
<arg1 key="${var:min}"
name="min" resource="false"/>
<arg2 key="${var:max}"
name="max" resource="false"/>
<var>
<var-name>min</var-name>
<var-value>1</var-value>
</var>
<var>
<var-name>max</var-name>
<var-value>5</var-value>
</var>
</field>
</form>

Message in Resources file is

errors.range={0} is not in the range {1} through {2}.

And iam getting java script as like this


function intRange () {
this.aa = new Array("count", "No. of Items is not in the range null through null.", new Function ("varName", "this.min='1'; this.max='5'; return this[varName];"));
}

while sending that message itself it is sending null values
But range values are validating properly.

Iam getting alert message is "No. of Items is not in the range null through null."

what may be the problem iam not getting.
please give me solution for this
 
Sai Priya
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi vamsi,
Me too having the same kind of problem,
If you get any solutions please post here.

thanks
 
vamsi mummadi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
please any one try to solve my problem. I tried so many options but nothing worked. please i need the solution very urgently.
thank you
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You got the name attribute of arg1 and arg2 wrong. Change it to "intRange" and try.
 
vamsi mummadi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi purushothaman
i didnt get what you are saying. can you please send details where i have to change that intRange.
thank you
vamsi
 
Purushoth Thambu
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try with these changes

<arg1 key="${var:min}"
name="intRange" resource="false"/>
<arg2 key="${var:max}"
name="intRange" resource="false"/>
 
vamsi mummadi
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Purushothaman
thank you very much. that started working.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic