You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Scott Purcell <sp...@vertisinc.com> on 2005/03/23 18:55:19 UTC

Action Question

Hello,
 
I have a form, which has an attached bean. I am doing validation, so I have good data going to my action.
 
In the action, I take the bean with good data, and hand it to a DTO object which updates the database with the new user supplied information. What can I do in the Action if my DTO object returns false (Could not update database because of some condition).  I know I can find a mapping and send it somewhere, but the user just filled out a large form, and I would like to send them back to the form, where the data is, and show them a message there. I tried using the Failure (see below) but when it goes to the newUser.jsp page it is blank. The data they just entered is not there.
 
 
I know how to do this in a ActionForm, but how in an Action?
 
Here is my action mapping:
    <action path="/newUser-submit"
      type="com.ddi.dealer.action.admin.CreateNewUserAction"
      name="newuserbean"
      scope="request"
      input="/jsp/admin/newUser.jsp"
      validate="true">
      <forward name="Success" path="/jsp/admin/mainAdmin.jsp" />
      <forward name="Failure" path="/jsp/admin/newUser.jsp" />
    </action>

 
Here is the action piece.
BeanUtils.copyProperties(usersbean, userbo);
    boolean recordInsert = userbo.insertNewUser();
 
    if (recordInsert) {
      actionforward = mapping.findForward("Failure");
    } else {
      actionforward = mapping.findForward("Success");
    }
    return actionforward;
 
I just would like to be able to return them to their form where they just entered all the data, and let them try again.
 
Thanks,
Scott