tags:

views:

13

answers:

1

Hi, i have a problem, i have my login with Strits2, Tiles2 and Struts xml validations, when i run my webapp the first page is the login and the struts2 xml validator send me the error, how do i tell that for the first time do not validate until submit?

    <action name="loginPage"  class="com.webapp.login.action.LoginAction">
        <result name="input" type="tiles">loginPage</result>
        <result name="success" type="tiles">loginPage</result>
    </action>
A: 

Whenever you want to go to a "blank form", you should execute the input() method of your Action. This tells Struts 2 that you do not want to perform any validation for the action:

<action name="loginPage"  class="com.webapp.login.action.LoginAction" 
        method="input">
    <result name="input" type="tiles">loginPage</result>
    <result name="success" type="tiles">loginPage</result>
</action>

Then, you should submit your login form to another action definition that executes the default action execute(). Struts 2 will then try to perform Action validation:

<action name="loginPageSubmit"  class="com.webapp.login.action.LoginAction">
    <result name="input" type="tiles">loginPage</result>
    <result name="success" type="tiles">loginPage</result>
</action>
gpeche