struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralf Fischer" <>
Subject Re: jsp page with s:action to call an action with a redirect-action
Date Thu, 01 May 2008 15:19:07 GMT

On Wed, Apr 30, 2008 at 2:21 AM, crappycrumpet <> wrote:
>  Ralf Fischer-2 wrote:
>  >
>  > Please tell us exactly what you want to do, as there might be a
>  > simpler solution to your problem.
>  >
>  Okay I don't have hibernate and this is what I'm sort of doing. Let's say
>  that I have a table of staffs, offices and things_assignment (which links
>  staffs and stuff to offices and whatever). I'm displaying rows of staffs
>  with the office they are assigned to. There are many solution to this... I
>  mean I can write an sql to grab the property as well as the staff and dump
>  them in a Staff object that has property object inside it (and whatever else
>  that can be assigned to a staff), that would make sense I just want to keep
>  things separate.

That's fine.

>  Ralf Fischer-2 wrote:
>  > As your workaround seems to be to "invoke back" actionA from your
>  > example, I guess there's another result for actionA which then renders
>  > the data which results from actionB into the page.
>  > This can either be
>  > done using the action chaining (which seems to be discouraged as I've
>  > learned from this maling list) where you don't have to invoke the
>  > action from the JSP but as a result directly, or simply render the
>  > data inside the action tag, doing something like this:
>  > | <s:action namespace="/foo" name="bar" executeResult="false">
>  > |   <s:property value="myPropertyFromTheBarActionImplementation" />
>  > | </s:action>
>  >
>  Yes actionA finds record A from a field in record B which is fetch from
>  actionB, and actionA displays the 'name' attribute from a. ActionA from
>  actionB was only called once so there's no 'invoke back'.
>  So the intention originally was actionB renders nothing but redirect to
>  actionA which renders something, which works when called directly to actionB
>  but when actionB is called from part of a JSP (say when I'm rendering rows
>  of objects C and want to display object A's name in one of the column, which
>  is associated to C via object B's CId [ I mentioned before was meant to
>  be b.CId] and blahId), but when I actually try that it doesn't move to
>  actionA after performing actionB.

Hum. So you use action B just to get Objects of type B and don't
render anything else. This surely can be done with actions but IMO is
most likely not the way they were intended to use. If you don't use
Hibernate, as you mentioned above, could this relation not be resolved
in one simple join within the select statement? Surely it would
perform better.

I always implement action according to the actions a user wants to
perform on the page, almost always this are the typical use cases
which you have on the page (e.g. "login", "send message to friend",
"list staff"). To me it looks like you are trying ot wrap your
entities with actions, like you have actions as "read staff", "read
offices" and "read thing_assingment". This is of course a good way to
do things if you want to create pages to view lists of each of the
tables, or display a detail view on each item of the object in
question, but it doesn't mean that the office action must not select
data from the staff entity to display the staff currently located
there. This is why entity handling/mapping is usually done in some
entity beans or DAO classes which can easily be invoked from arbitrary

>  I was looking at action chaining and the page say to use 'redirect' or
>  'redirectAction' instead which is the approach I chose but it didn't do what
>  I thought it would.
>  Anyhow the workaround works I'm more just curious as to why redirect-action
>  doesn't work in this instance. I mean surely not all <s:action with
>  executeResult set to true would render a separate HTTP header.... right? ...
>  or do they?

The redirect results work just fine as long as you don't invoke the
action resulting in a redirect from inside another result, e.g. a JSP
page. As mentioned in my last mail you cannot redirect a request
easily once JSP rendering has started which is usually the case when
the <s:action/> tag is executed, as it's embedded inside such a result
which leads to rendering the HTTP header and the HTTP response body
afterwards. There are ways to do this, but I wouldn't recommend it
anyway. In this instance it seems you either have to restructure your
actions, make use of the result rendering inside the <s:action/> tags'
body, or have no other choice than to use action chaining.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message