struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From taj uddin <tajuddi...@yahoo.com>
Subject Validate() method not working
Date Tue, 10 Feb 2009 13:02:35 GMT
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>




      
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message