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

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
 
Well don't expect me to do the dishes! This ad has been cleaned for your convenience:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic