• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Automatically forward to Action

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Guys -

I have a link set up like so:

"<a href=<s:url action="DemoSrs"/> target="content_frame">continue</a>"

(using the code tags is causing most of the elements to disappear - too many brackets I think)

I'd like to have it automatically triggered - right now it is the only element on a page, and I need it to advance a survey I am setting up.

I've tried using a <jsp:forward> tag using the <s:url...> field as the target, but the page errors out with an "expected quote" error.

Anybody have any quick ideas?

Thanks!
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sam,
How about using a JavaScript function to call it?
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Testing the code mentioned above:
 
Sam Gardner
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, I thought of that, but I've been trying to avoid using JavaScript.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sam Gardner wrote:Yeah, I thought of that, but I've been trying to avoid using JavaScript.


Why? You aren't relying on JavaScript here. If a user has JavaScript turned off, he/she can still click the link by hand.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want the link "automatically triggered" then why do you need it at all? Just go to the next page as a result of the action processing/result definition.
 
Sam Gardner
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the audience for this particular site needs everything to be as simple as possible, and that particular page is being used in between questions of surveys that have 50 or more questions, so if someone had JavaScript disabled it would be considerably annoying.

This is the "flow" that I need to have working:

1) Survey page, displaying one struts item that uses a dynamically generated list (based on the question number stored in a session variable, so I can display progress and such) in Survey.action

2) Clicking the submit button on the question page triggers Forward.action, which increments the question number and writes the previous answer to the database.

3) I need to refresh the Survey.action page, so that it can display the new question. Right now I have Forward.action dispatch to a second page, and then link back to the Survey.action page.

I want step 3 to happen automatically, but I need the survey page to be refreshed in order to get the new question displayed, and to keep this system flexible for multiple surveys.

If there's no other way that doesn't involve using JavaScript with the link I already am using, I guess I'll have to do that, but I'd really prefer not to. Is there some way I can specify the action definition in struts.xml to forward to an action url instead of just a JSP?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I'm completely missing something about what you're saying, because the way I read that you're just submitting a form and redirecting to another page--like any other form processing, normal post-redirect.

As far as redirecting to an action, of course--you can either just put in the full action path to a normal "redirect" result type, or use "redirectAction" and put in only the action name.

You can also use OGNL expressions in the result configuration (whether XML- or annotation-based) if you need to pass something on in the redirect.
 
Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic