Re: jsp page with s:action to call an action with a redirect-action

2008-05-01 Thread Ralf Fischer
Hi!

On Wed, Apr 30, 2008 at 2:21 AM, crappycrumpet <[EMAIL PROTECTED]> 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:
>  > | 
>  > |   
>  > | 
>  >
>
>  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 [b.id 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
actions.

>  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   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  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  tags'
body, or have no other choice than to use action chaining.

Bye,
-Ralf

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: jsp page with s:action to call an action with a redirect-action

2008-04-29 Thread crappycrumpet

Hi Ralf,


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. 


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:
> | 
> |   
> |  
> 

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 [b.id 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.

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.

Hope I'm making sense here...
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 http://www.nabble.com/jsp-page-with-s%3Aaction-to-call-an-action-with-a-redirect-action-tp16951812p16973314.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: jsp page with s:action to call an action with a redirect-action

2008-04-29 Thread Ralf Fischer
Hi there,

On Tue, Apr 29, 2008 at 3:46 AM, crappycrumpet <[EMAIL PROTECTED]> wrote:
>
>  Hi,
>
>  I have a problem where I have a page (let's call it a.jsp) which calls an
>  action using   to actionA in namespaceA, using redirect-action, which display the name
>  attribute in object a. (both implements modelDriven).
>
>  actionB take parameter b.id to find the object b.
>  actionA take parameter a.blahId to find object a.
>
>  so in my struts.xml I have the following setup.
>  
>   
>  show_name.jsp
>   
>  
>  
>   
>  
> actionA
> namespaceA
> b.thingyId
>  
>   
>  
>
>  Now it works fine when I call it by going to the url
>  http://XXX/namespaceB/actionB.action?b.id=123 but when I call it from a jsp
>  using  like below, it would do the method for actionB but not
>  continue to do actionA.
>
>  <%@ taglib prefix="s" uri="/struts-tags" %>
>  
> 123
>  

As you might guess, when the JSP rendering is in progress, the HTTP
headers are already rendered ("on the net"), so they can't be modified
by the server anymore. Thus, an embedded action invoked by  cannot send a redirect- or action-redirect-result.

Please tell us exactly what you want to do, as there might be a
simpler solution to your problem.

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:

| 
|   
| 

This works because the action tag does not execute the "usual" action
result from the mapping, but rather pushes the action object (and IIRC
the model, if you use ModelDriven) onto the stack, and then evaluates
the action tag body.

Cheers,
-Ralf

>
>  Any clue on why it doesn't work and how I can get it to work?
>
>  Thanks!
>  CC
>  --
>  View this message in context: 
> http://www.nabble.com/jsp-page-with-s%3Aaction-to-call-an-action-with-a-redirect-action-tp16951812p16951812.html
>  Sent from the Struts - User mailing list archive at Nabble.com.
>
>
>  -
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>

,

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: jsp page with s:action to call an action with a redirect-action

2008-04-28 Thread crappycrumpet

Currently I have made a work around by assigning the result for actionB to
b.jsp which invoke actionA using another  and parsing the
parameter through using . I just thought perhaps you can just
redirect action without a page in between the two actions. Oh well.

cheers. 
-- 
View this message in context: 
http://www.nabble.com/jsp-page-with-s%3Aaction-to-call-an-action-with-a-redirect-action-tp16951812p16952874.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



jsp page with s:action to call an action with a redirect-action

2008-04-28 Thread crappycrumpet

Hi,

I have a problem where I have a page (let's call it a.jsp) which calls an
action using 
  
 show_name.jsp
  


  
 
actionA
namespaceA
b.thingyId
 
  


Now it works fine when I call it by going to the url
http://XXX/namespaceB/actionB.action?b.id=123 but when I call it from a jsp
using  like below, it would do the method for actionB but not
continue to do actionA.

<%@ taglib prefix="s" uri="/struts-tags" %>

123


Any clue on why it doesn't work and how I can get it to work?

Thanks!
CC
-- 
View this message in context: 
http://www.nabble.com/jsp-page-with-s%3Aaction-to-call-an-action-with-a-redirect-action-tp16951812p16951812.html
Sent from the Struts - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]