Struts2 JPA Validation error how to forward to action and not lose ActionErrors messages ?

Posted by Sebastien Dionne on Stack Overflow See other posts from Stack Overflow or by Sebastien Dionne
Published on 2011-03-13T03:15:09Z Indexed on 2011/03/13 8:09 UTC
Read the original article Hit count: 278

Filed under:
|
|

I'm using Hibernate validator 4.1 to validate my entity.

I have a dashboard that I can access from the action : viewDashboard. In my action, I load 2 List in my acion like this.

public String execute() throws Exception {

    listDocteur = service.listDocteur();
    listUser = service.listUser();

    return SUCCESS;
}

In the DashBoard, I have a submit that can add a User.

<action name="saveUser" class="com.test.action.CreateUserAction" method="execute">
   <interceptor-ref name="mybasicStackWithValidation" >
   </interceptor-ref>
   <result name="input">/WEB-INF/jsp/viewDashboard.jsp</result>
   <result name="success" type="redirectAction">viewDashboard</result>
</action>

if I submit invalid value, I'll see the error messages, but I'll lose my 2 Lists. If I have a type="redirectAction".. I lose the error messages.

in Struts 1, I would forward to the action viewDashboard.do without a redirect and that will works.. but How to do that in Struts2 ?

© Stack Overflow or respective owner

Related posts about validation

Related posts about struts2