You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by taj uddin <ta...@yahoo.com> on 2009/02/10 14:02:35 UTC
Validate() method not working
Hi,
In my application I have used the validate() method but to my surprise i found that validate method was not being called at all.
What ever the code i have placed in the validate method was not being executed. I doubt there was some problem with the interceptors which i have included in the xml file.
Here is my code of validate method:
/* (non-Javadoc)
* @see com.opensymphony.xwork2.ActionSupport#validate()
*/
@Override
public void validate() {
List<Object> loginErrors= new ArrayList<Object>();
if ((getUserId() == null) && (getPassword() == null)){
loginErrors.add(getText(GuiConstants.LOGIN_REQUIRED));
}
List<Object> userIdErrors=ValidatorUtils.validateString("User ID", getUserId(), 1, 15, true);
if(userIdErrors!=null){
loginErrors.addAll(userIdErrors);
}
List<Object> passwordErrors=ValidatorUtils.validateString("Password", getPassword(), 6, 10, true);
if(passwordErrors!=null){
loginErrors.addAll(passwordErrors);
}
setActionErrors(loginErrors);
}//end validate
Below is the xml file:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="fps-Default" extends="struts-default">
<interceptors>
<interceptor-stack name="defaultFPSStack">
<interceptor-ref name="exception" />
<interceptor-ref name="alias" />
<interceptor-ref name="servlet-config" />
<interceptor-ref name="prepare" />
<interceptor-ref name="i18n" />
<interceptor-ref name="chain" />
<interceptor-ref name="debugging" />
<interceptor-ref name="profiling" />
<interceptor-ref name="fileUpload" >
<param name="maximumSize">104857600</param>
</interceptor-ref>
<interceptor-ref name="static-params" />
<interceptor-ref name="params" />
<interceptor-ref name="conversionError" />
<interceptor-ref name="validation" />
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="defaultFPSStack" />
<!-- Global Results -->
<global-results>
<result name="error">/fps_error.jsp</result>
<result name="invalidUser">/login.jsp</result>
</global-results>
<action name="login" class="com.abc.presentation.action.LoginAction">
<result name="success" type="redirect-action">
<param name="actionName">viewHome.action</param>
<param name="namespace">/h</param>
</result>
<result name="failure">login.jsp</result>
<result name="input">login.jsp</result>
</action>
</package>
</struts>
Re: Validate() method not working
Posted by Sonny Gill <so...@gmail.com>.
Hi,
How come you posted the same (except for slightly different subject)
message twice?
Anyway, I answered your question while replying to the other mail. May
be we should continue any further discussion in that email.
Cheers,
Sonny
On Tue, Feb 10, 2009 at 9:02 PM, taj uddin <ta...@yahoo.com> wrote:
> Hi,
>
> In my application I have used the validate() method but to my surprise i found that validate method was not being called at all.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org