File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts2: From One Action to another

 
Dennis Labajo
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi y'all!

What's the trick to calling one action from another action without using redirect? e.g.

Here's my struts.xml file:


Thanks.

 
Dennis Labajo
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BTW..forgot to add,... I'm able to call/execute 'First' but never gets to 'Second'.

Thanks again
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean, "calling one action from another"? What specifically are you trying to do? There's no reason it would magically "continue" to another action.
 
Dennis Labajo
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:What do you mean, "calling one action from another"? What specifically are you trying to do?


I'm trying to make action class First execute, return 'success', and then make action Second run without doing a "redirect". So far the only way I am able to run First and then Second is if I explicitly use result type="redirect" which I do not want, e.g.




David Newton wrote:There's no reason it would magically "continue" to another action.





Anyways, by not explicitly specifying a result type I am expecting a "dispatcher" result type as my default (which acts as a forward in lieu of redirect?) because my struts xml extends struts-default.


 
Ananth Chellathurai
Ranch Hand
Posts: 349
Eclipse IDE Hibernate Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Are you aware of action chaining in struts2? This URL should help you.
 
Dennis Labajo
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ananth Chellathurai wrote:Hi,
Are you aware of action chaining in struts2? This URL should help you.


Ananth, that's exactly what I was looking for. Thanks!
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Action chaining is almost always never the best answer (or even a good one). It leads to difficult-to-maintain applications.
 
Dennis Labajo
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:Action chaining is almost always never the best answer (or even a good one). It leads to difficult-to-maintain applications.


Why is that? So what's the best or good answer? Am I back to making dispatcher work and is that a better approach? If it is, I guess I'm back to my first question...what's the trick to making this work? I can get it to forward to a servlet but not for an action. Forwarding to an action results in a '404' error.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forwarding?

You still haven't said precisely what you're trying to do.
 
Dennis Labajo
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:Forwarding?

You still haven't said precisely what you're trying to do.


geesh, thanks anyway!
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not understand your response.

If I don't know exactly what you're trying to accomplish, how could I possibly give you advice about cleaner ways to accomplish it? Example:

You: I am action chaining to set up some variables I need available in the JSP.
Me: Have you considered implementing Preparable, or using the <s:action> tag (with the caveat that the <s:action> tag has some subtle "gotchas")?

But I'd really rather not spend my time guessing what your use case is or specific needs are when you can just tell me and make the process much more efficient. But if you're not willing or able to do so, that's fine too; I'm okay with that.
 
Dennis Labajo
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see...ok, let me try this again tonight and will provide a much better detail. I have to change gears and work on something else right now. Thanks Dave.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic