• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

STRUTS VALIDATOR FRAMEWORK

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am new to struts framework . I am developing a web application and i need to use validator framework to validate the input provided by the User...... The problem i am facing here is if there is any error (user provides wrong input) then the error messages are being displayed but i am unable to hold the invalid data entered by the user...... and moreover all my fields get empty if user provides wrong value in only one field................. can any one please tell me what to do..................


1----------plugin tag in struts-config.xml is
<!DOCTYPE
struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<struts-config>
..
.
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/org/apache/struts/validator/validator-rules.xml,
/WEB-INF/validation.xml"/>
</plug-in>
-----------------------------
2--------- validation.xml


<form-validation>
<formset>
<form name="loginForm1">
<field property="userLoginID" depends="required">
<arg key="inputForm.userLoginID"/>
</field>

<field property="password" depends="required">
<arg key="inputForm.password"/>
</field>
</form>
</formset>
</form-validation>
----------------------------------------

3.-------------------------Action Mapping

<form-beans>
<!-- ========== Form Bean Definitions ================================ -->
<form-bean name="loginForm1"
type="net.sample.ui.form.LoginForm" />
</form-beans>
<action-mappings>
<action path="/signIn"
type="net.sample.ui.actionclass.SignInAction"
name="loginForm1"
scope="request"
input="/jsp/common/login.jsp"
validate="true">
<forward name="ACTION_FORWARD_SUCCESS"
path="/jsp/common/home.jsp" />
</action>
</action-mappings>
----------------------------------------

4--------------- FormBean
package net.sample.ui.form;
public class LoginForm extends ValidatorForm{
public LoginForm() {
}
private String userID;
private String password;
public String getUserID() {
return userID;
}

/**
* @param userID the userID to set
*/
public void setUserID(String userID) {
this.userID = userID;
}

/**
* @return the password
*/
public String getPassword() {
return password;
}

/**
* @param password the password to set
*/
public void setPassword(String password) {
this.password = password;
}
}

----------------------------------------
5.-------------Action Class

contains only one statement inside execute function

return map.findForward("ACTION_FORWARD_SUCCESS");


--------------------

I tried all the possible things i could do......... but in vain:banghead:
reply
    Bookmark Topic Watch Topic
  • New Topic