A night's decent sleep and I realize what the solution is.  Find the action forward but
dont save the name of the forward into the request scope. Save
the forward's path instead!

if ( !isTokenValid() )  {
     // transaction error
     saveErrors( ... )
     ActionForward fwd = mappings.findForward("transaction-invalid");
     request.setAttribute( "com.db.project.AFTER_TRANSACTION_INVALID", fwd.getPath() );

     return mapping.findForward( "invalid-form-input" );
}

The forward path, of course, is a reference to the next action

      <forward name="transaction-invalid"        
path="/AdsurdCalc.do?action=promptForm" />

Now everything makes sense. I simply use a bog standard HTML Form tag
and a bit of java script to submit the form.

<html:errors/>

<logic:present name="com.db.project.AFTER_TRANSACTION_INVALID" >
   <form action="<%= request.getAttribute("com.db.project.AFTER_TRANSACTION_INVALID") 
%>" >
     Please continue to the restart page
      <input type="button" value="Continue" onclick="this.form.submit();" >
   </form>
</logic:present>

So after a transaction token error I give the user the option to move FORWARD
as well back. Going backwards usually results in the same attempt to
insert the row in to the database again [double-insertion] which
is what transaction tokens are designed to protect. So the user ends
up getting very __frustrated__ after going round and around in circles.
Not good for any professional web application!

http://www.xenonsoft.demon.co.uk/axioms2.html

--
Peter Pilgrim                 ++44 (0)207-545-9923
                                                      //_\\
"Mathematics is essentially the study of islands of  =======
disparate subjects in a sea of ignorance."           || ! ||
Andrew Wiles _____________


---------------------------------------- Message History 
----------------------------------------


From: Peter Pilgrim/DMGIT/DMG UK/DeuBa@DMG UK on 20/12/2001 16:37

Please respond to "Struts Users Mailing List" <[EMAIL PROTECTED]>

To:   [EMAIL PROTECTED]
cc:
Subject:  Transaction Token: How can a html:form submit a forward



When you transaction token invalid you normally forward
to nice smiling double transaction screen and print a nice error message.

You want to prevent or suggest that user not hit the [BACK] button in the
browser.

I would like to put a simple button "Continue" that forwards to the "promptForm"
page.

if ( !isTokenValid() )  {
     // transaction error
     saveErrors( ... )
     ActionForward fwd = mappings.findForward("transaction-invalid");
     request.setAttribute( "com.db.project.AFTER_TRANSACTION_INVALID", fwd );

     return mapping.findForward( "invalid-form-input" );
}

Do you see what I am doing here? I am finding a forward "transaction-invalid"
to allow the user to go FORWARD rather than BACKWARDS.
In each ActionMapping I can declare a "transaction-invalid" that redirect to
the same action and forward to the "promptForm" screen.

    <action    path="/AbsurdCalc"
               type="com.db.project.jsp.actions.AbsurdCalc"
               name="calcForm"
              scope="request"
           validate="false" >
      <forward name="promptForm"        path="/calcForm.jsp"/>
      <forward name="success"           path="/calcResul.tjsp"/>
      <forward name="transaction-invalid        
path="/AdsurdCalc.do?action=promptForm" />
    </action>

So I would like to write in "invalid-form-input.jsp" something like this

<html:errors/>

<logic:present name="com.db.project.AFTER_TRANSACTION_INVALID" >
   <html:form   forward="<%= 
request.getAttribute("com.db.project.AFTER_TRANSACTION_INVALID") %>" >
     Please continue to the restart page
      <html:button value="Continue" />
   </html:form>
</logic:present>

I know <html:form> does not support a forward tag attributes. Any Suggestion?

--
Peter Pilgrim                 ++44 (0)207-545-9923
                                                      //_\\
"Mathematics is essentially the study of islands of  =======
disparate subjects in a sea of ignorance."           || ! ||
Andrew Wiles __________________________/\________/\__||_!_||__



--

This e-mail may contain confidential and/or privileged information. If you are not the 
intended recipient (or have received this e-mail in error) please notify the sender 
immediately and destroy this e-mail. Any unauthorized copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden.



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






--

This e-mail may contain confidential and/or privileged information. If you are not the 
intended recipient (or have received this e-mail in error) please notify the sender 
immediately and destroy this e-mail. Any unauthorized copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden.



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

Reply via email to