• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

regarding validations

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i want to use validator framework .............
with required, integer,minlength validations now i also want to check for the range it should be greater than zero .How is it possible ???
 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

In the Form class extend your class from ValidatorAction rather than ActionForm. You must have Validation.xml and validator-rules.xml in your WEB-INF.

Please find a small piece of code attached.

*****************
Form class
******************
public class LoginForm extends ValidatorForm
{
private String userid =null;
private String password =null;

public void setUserid( String userid)
{
this.userid=userid;
}
public void setPassword( String password)
{
this.password=password;
}
public String getUserid()
{
return userid;
}
public String getPassword()
{
return password;
}

}

***************************
Validation.xml
**************************
<form name="loginForm">
<field property="userid" depends="required">
<arg0 key="loginForm.userName" />
</field>
<field property="password" depends="required">
<arg0 key="loginForm.password" />
</field>
</form>

***************************
struts-config.xml
**************************
<form-beans>
<form-bean name="loginForm"
type="com.abc.xyz.LoginForm" />
</form-beans>

********************
index.jsp
*******************
<tr>User ID:<td width="62%"><html:text property="userid" /></td>
</tr>
<tr>Password:<td><html assword property="password" /></td>
</tr>

Hope that works for you.
Regards,
Roshani.
 
nishit hegde
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i want multiple validations ie required,integer,intrange,minlength
how to write validations.xml
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic