You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by AngeloChen <an...@yahoo.com.hk> on 2007/08/17 11:52:43 UTC

validate never got called

Hi,

I have an ActionForm like following, the setter got called while validate
method never, why?

public class MyForm extends ActionForm {

    private String username;
    private String password;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
        System.out.println(username);
        System.out.println("setuserName");
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public MyForm() {
    }

    public void reset(ActionMapping actionMapping, ServletRequest
servletRequest) {
        super.reset(actionMapping, servletRequest);    //To change body of
overridden methods use File | Settings | File Templates.
    }

    public ActionErrors validate(ActionMapping actionMapping, ServletRequest
servletRequest) {

        System.out.println("validateing");
        ActionErrors errors = new ActionErrors();
        errors.add("test", new ActionMessage("test"));
        return errors;
      //  return super.validate(actionMapping, servletRequest);    //To
change body of overridden methods use File | Settings | File Templates.
    }

the struts-config.xml as follows:

<struts-config>
    <form-beans>
        <form-bean type="pkg.MyForm" name="loginForm"/>
    </form-beans>
    <global-forwards>
        <forward path="/pages/login.jsp" name="login"/>
    </global-forwards>
    <action-mappings>
        <action path="/login" scope="request" type="pkg.MyAction"
name="loginForm" validate="true"
                input="/pages/errors.jsp"/>
    </action-mappings>
</struts-config>

}
-- 
View this message in context: http://www.nabble.com/validate-never-got-called-tf4284786.html#a12196967
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


R: validate never got called

Posted by Amleto DI SALLE <di...@di.univaq.it>.
Your class have to extend ValidatorForm and not ActionForm.


BR
/Amleto


-----Messaggio originale-----
Da: AngeloChen [mailto:angelochen960@yahoo.com.hk] 
Inviato: venerdì 17 agosto 2007 11.53
A: user@struts.apache.org
Oggetto: validate never got called



Hi,

I have an ActionForm like following, the setter got called while
validate method never, why?

public class MyForm extends ActionForm {

    private String username;
    private String password;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
        System.out.println(username);
        System.out.println("setuserName");
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public MyForm() {
    }

    public void reset(ActionMapping actionMapping, ServletRequest
servletRequest) {
        super.reset(actionMapping, servletRequest);    //To change body
of
overridden methods use File | Settings | File Templates.
    }

    public ActionErrors validate(ActionMapping actionMapping,
ServletRequest
servletRequest) {

        System.out.println("validateing");
        ActionErrors errors = new ActionErrors();
        errors.add("test", new ActionMessage("test"));
        return errors;
      //  return super.validate(actionMapping, servletRequest);    //To
change body of overridden methods use File | Settings | File Templates.
    }

the struts-config.xml as follows:

<struts-config>
    <form-beans>
        <form-bean type="pkg.MyForm" name="loginForm"/>
    </form-beans>
    <global-forwards>
        <forward path="/pages/login.jsp" name="login"/>
    </global-forwards>
    <action-mappings>
        <action path="/login" scope="request" type="pkg.MyAction"
name="loginForm" validate="true"
                input="/pages/errors.jsp"/>
    </action-mappings>
</struts-config>

}
-- 
View this message in context:
http://www.nabble.com/validate-never-got-called-tf4284786.html#a12196967
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

No virus found in this incoming message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.11.17/951 - Release Date:
13/08/2007 10.15
 

No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.11.17/951 - Release Date:
13/08/2007 10.15
 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org