Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

how to do "redirect-action" to some action from within ActionSupport?

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hy,

Can , please, someone help me with this:

How can I do a "redirect-action" to some action from within ActionSupport ?

I want to write an ActionSupport class that will insert some data in the DB and if succeeds , I want to redirect to some action set in this ActionSupport ( an action name, as String, is provided in this ActionSupport class ) and if not, just go to error.jsp

Can this be done, and how would I map this action in a strut.xml file ?

something like this:

 
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
You'd define a "success" result of the "redirectAction" type.
 
Michael Brown
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, If I want to use struts.xml

But I want to create redirect-action within code of my ActionSupport class...

How to do that?

 
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
Why? There's almost never any reason to build a result dynamically in the code itself (and I suspect it's difficult enough to be impractical). What are you trying to do that you don't believe can't be done via normal means?
 
Michael Brown
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, I made a small mistake: I need just an ordinary "redirect" , not "redirect-action"

Why? There's almost never any reason to build a result dynamically in the code itself (and I suspect it's difficult enough to be impractical). What are you trying to do that you don't believe can't be done via normal means?



Let's say I have ActionSupport "a" whose view is "a.jsp" and on submit I "call" ActionSupport "b" that needs to insert some data in the DB and redirect to action "a" ( go to the beginning )

And what if I have N such "circles" for every table in the DB.
That way I would map N actions "a" + N actions "b" in the struts.xml

I want to make universal action "b" that will do the insertion of the data no matter how that data looks like , and redirect to some action that I specified in some String...
That way I don't need to map those N "b" actions in the struts.xml

This is just, of course, simplified version of what I'm doing...

 
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
Use a dynamic result? You can use OGNL expressions in result declarations.

I don't understand what you're saying, though, and so far I don't see anything that would require generating dynamic configurations.
 
Michael Brown
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

Thank you very much for your answers!
I appreciate it!

Use a dynamic result? You can use OGNL expressions in result declarations.



This sounds like a solution to my problems...

I'll give it a try!
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why writing to DB using struts ActionSupport? This class is used for request processing.
In your scenario ActionSupport B has no real meaning in terms of request. It just write something to DB.
So why don't you create DAO and use it inside your ActionSupport A to read/write from/to DB? I don't see any reason to using ActionSupport in such a strange manner.
 
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
@Pavel: he said the DB work was being done from the action class, not how.
 
Liar, liar, pants on fire! refreshing plug:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic