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 15:23:34 UTC

problem with validate() method

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.

I'm submitting the userId and password from my login page which was mapped to Loagin action class which contains validate method.

Here is my code of validate method in my LoginAction:

/* (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>

Pls kindly help me out as to what should be done to make my validate method work



      

Re: problem with validate() method

Posted by Sonny Gill <so...@gmail.com>.
You need to include the workflow interceptor for validate() to be invoked.

Cheers,
Sonny

On Tue, Feb 10, 2009 at 10:23 PM, taj uddin <ta...@yahoo.com> wrote:

> 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