Before forwarding to failure try this... 

Action:

  Public ActionForward execute(Mapping mapping Form form, ...) {

    YourFormClass newuserbeanform = (YourFormClass)form;
    .
    .
    .

    boolean recordInsert = userbo.insertNewUser();
 
//By The way this looks backwards... I thought true was a success???
    if (recordInsert) {
      request.setAttribute("newuserbean", newuserbeanform);
      actionforward = mapping.findForward("Failure");
    } else {
      actionforward = mapping.findForward("Success");
    }

That will make the current form available to the jsp and it should show
the data you have in it.

Al



-----Original Message-----
From: Scott Purcell [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 23, 2005 11:55 AM
To: user@struts.apache.org
Subject: 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

                                                 

 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to