aspose file tools*
The moose likes Struts and the fly likes STRUTS VALIDATOR FRAMEWORK Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "STRUTS VALIDATOR FRAMEWORK" Watch "STRUTS VALIDATOR FRAMEWORK" New topic
Author

STRUTS VALIDATOR FRAMEWORK

Mohd Junaid Khan
Greenhorn

Joined: Mar 22, 2011
Posts: 1
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
 
wood burning stoves
 
subject: STRUTS VALIDATOR FRAMEWORK