Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Struts Forward to an Action from an to Action and URLs

Reply
Thread Tools

Struts Forward to an Action from an to Action and URLs

 
 
rjweytens
Guest
Posts: n/a
 
      06-22-2004
Hello,

I am in the process of developing a web app using Struts. I have a
situation where I am calling an action to add some information to a
database, and if the add is successful, the action will forward to
another action that brings up a confirmation page that shows the id #
of the record that was added along with the added information. When
the confirmation page comes up, the URL in the page is the URL for the
action that added the record to the database, not the URL for the
action that generated the confirmation page. Therefore, when the
refresh button is pressed, the action will is executed again and
another record is added to the database.

I've added the redirect="true" parameter to my actions, but that did
not change the URL. I have also read about using tokens, but it seems
to me that the URL should stay current with the page. Any
suggestions?

Thanks
 
Reply With Quote
 
 
 
 
Oscar kind
Guest
Posts: n/a
 
      06-22-2004
rjweytens <(E-Mail Removed)> wrote:
> I am in the process of developing a web app using Struts.

[...]
> When the confirmation page comes up, the URL in the page is the URL for
> the action that added the record to the database, not the URL for the
> action that generated the confirmation page. Therefore, when the
> refresh button is pressed, the action will is executed again and
> another record is added to the database.
>
> I've added the redirect="true" parameter to my actions, but that did
> not change the URL. I have also read about using tokens, but it seems
> to me that the URL should stay current with the page. Any
> suggestions?


Instead of using an ActionForward to another view, try redirecting to
another action. This confirmation action basically does nothing but return
an ActionForward to the confirmation view.


kind regards,
Oscar

--
Oscar Kind http://home.hccnet.nl/okind/
Software Developer for contact information, see website

PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
 
Reply With Quote
 
 
 
 
rjweytens
Guest
Posts: n/a
 
      06-23-2004
Oscar,

I don't follow you. I am forwarding from an Action to another Action,
which is what I believe you are suggesting I do.

i.e.

User presses submit button ---> AddAction ---> Confirmation Action ---
> Confirmation Page

 
Reply With Quote
 
Oscar kind
Guest
Posts: n/a
 
      06-23-2004
rjweytens <(E-Mail Removed)> wrote:
> I don't follow you. I am forwarding from an Action to another Action,
> which is what I believe you are suggesting I do.
>
> i.e.
>
> User presses submit button ---> AddAction ---> Confirmation Action
> ---> Confirmation Page


I meant something like this:
1. User presses submit
2. AddAction adds record
3. AddAction redirects to confirmation URL (i.e. goes to browser).
4. User's browser goes to confirmation URL
5. ConfirmAction forwards to confirmation view
6. Confirmation view shows confirmation.

Step 4 is the important one: because the application uses the user's
browser as an intermediate step, the URL is updated correctly.

AFAIK, this should work. If not, I've some troubleshooting to do myself.


Oscar

--
Oscar Kind http://home.hccnet.nl/okind/
Software Developer for contact information, see website

PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2
 
Reply With Quote
 
Murray
Guest
Posts: n/a
 
      06-23-2004

> I've added the redirect="true" parameter to my actions, but that did
> not change the URL. I have also read about using tokens, but it seems
> to me that the URL should stay current with the page. Any
> suggestions?
>
> Thanks


redirect="true" should change the URL since it issues a client-side
redirect. Maybe you put it on the wrong forward? Or didn't restart your
server/context?


 
Reply With Quote
 
rjweytens
Guest
Posts: n/a
 
      06-23-2004
Here is the relevant section of my struts-config. See that the AddRFC
action forwards to the ConfNew action. ConfNew then forwards to
confNew.jsp. Hopefully this will help.

Thanks for your help thus far.

<!-- New RFC Page Action -->
<action path="/New"
type="rfc.NewRFCAction"
redirect="true"
scope="session">
<forward name="success" path="/new.jsp"/>
<forward name="error" path="/index.jsp"/>
</action>

<!-- Add RFC Action -->
<action path="/AddRFC"
type="rfc.AddRFCAction"
redirect="true"
name="RFCActionForm"
scope="request"
input="/new.jsp"
validate="true">
<forward name="success" path="/ConfNew.do"/>
<forward name="error" path="/new.jsp"/>
</action>

<!-- Confim RFC Add/Edit Page Action -->
<action path="/ConfNew"
type="rfc.ConfRFCAction"
redirect="true"
name="RFCActionForm"
scope="request"
validate="false">
<forward name="success" path="/confNew.jsp"/>
<forward name="error" path="/confNew.jsp"/>
</action>

<!-- Log out of application Action -->
<action path="/Logout"
type="rfc.LogoutAction"
redirect="true"
scope="request">
<forward name="success" path="/index.jsp"/>
<forward name="error" path="/index.jsp"/>
</action>
 
Reply With Quote
 
rjweytens
Guest
Posts: n/a
 
      06-25-2004
Still no resolution yet.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Struts 2 getRequestDispatcher forward to *.action Q1tum Java 3 11-24-2009 04:38 PM
adding action mapping to struts-config file in struts ros Java 0 05-15-2007 10:51 AM
Help:Action forward to jsp directly in struts avrootshell Java 3 10-19-2006 09:32 PM
Struts - forward to tiles from Action Gray Java 0 09-27-2005 06:54 PM
struts plug-in for struts-menu causing action not to preload dawnsk1@yahoo.com Java 0 02-14-2005 02:59 PM



Advertisments