You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Matthias Wessendorf <mw...@pironet-ndh.com> on 2005/10/13 09:28:56 UTC

[Struts 1.3] Using Commons Chains instead of Action(s)

Hi all,  

I have updated some apps to 1.3, that went pretty smooth :-)
(Thanks to the good documentation in wiki!!!)

I saw in struts-config DTD that for <action> element now the
attributes "catalog" and "command" were introduced.

I got a chain of commands to work (partly) w/ 1.3.
I now have two questions on working with chains instead of actions.

#1
How do I *caculate* the navigation inside of my command?
Or do I need something extra? After my chain of commands was
executed, I saw a blank page (yes... no ActionForward found ;-))

I have in struts-config something like that:
<action ...command="myChain" catalog="publishCat"...>
  <forward name="success" ...>
</action>

Is there a "key" for the Context object, to tell him "success" must be
used for finding the ActionForward object ?

#2
This is more a doubt on accessing formbeans in a command.
In my command I did the following to lookup my formBean object
(inside execute(Context cxt)):
FormularBean fb = (FormularBean) cxt.get(Constants.ACTION_FORM_KEY);
//org.apache.struts.chain.Constants

this works pretty well, but now my doubt... is this the "right" way ?


Thanks for any hint :-)


Best Regards
Matthias Weßendorf

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [Struts 1.3] Using Commons Chains instead of Action(s)

Posted by Joe Germuska <Jo...@Germuska.com>.
At 6:43 PM +0200 10/13/05, Matthias Wessendorf wrote:
>Wolfgang-
>
>I am now doing something like this
>inside of execute(Context context):
>
>ActionContext ctx = (ActionContext) context;
>...
>ActionMapping mapping = (ActionMapping)ctx.getActionConfig();
>ActionForward fw = mapping.findForward("success");
>
>Since the passed ContextIMPL is ServletActionContext, I think it will be
>ok... in any environment (portlet e.g)

If you aren't already extending any other class, your commands can 
inherit from ActionCommandBase, which may make the expectation that 
it be used with an ActionContext more clear -- it's just a simple 
command which casts the context and passes it to an abstract 
execute(ActionContext) method which you'd implement in your class.

One of the intentions behind moving creation of the ActionContext 
into ComposableRequestProcessor (after a brief experiment with trying 
to adapt any Context) was to be able to guarantee that all commands 
called by the ComposableRequestProcessor would be passed not just a 
Context, but an ActionContext.

Joe

-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"Narrow minds are weapons made for mass destruction"  -The Ex

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [Struts 1.3] Using Commons Chains instead of Action(s)

Posted by Matthias Wessendorf <ma...@matthias-wessendorf.de>.
Wolfgang-

I am now doing something like this 
inside of execute(Context context):

ActionContext ctx = (ActionContext) context;
...
ActionMapping mapping = (ActionMapping)ctx.getActionConfig();
ActionForward fw = mapping.findForward("success");

Since the passed ContextIMPL is ServletActionContext, I think it will be
ok... in any environment (portlet e.g)


Any comments?
-Matthias

On Thu, 2005-10-13 at 11:42 +0200, Wolfgang Gehner wrote:
> do:
> 
> ActiionMapping mapping = (ActionMapping) 
> context.get(org.apache.struts.chain.Constants.ACTION_CONFIG_KEY);
> ActionForward fw = mapping.findForward(forwardName);
> 
> context.setForwardConfig(fw);
> 
> Also see my Struts 1.3 dev suite (250MB download) at www.infonoia.com 
> (you need to register).
> We wrapped the above in our own ActContext class which extends 
> ServletActionContext and has context.setForward(forwardName)
> We also wrote a DispatchCmd, similar to DispatchAction, but for 
> commands, (so you have event handles like onSave(Act Context))
> 
> Also see our Struts 1.3 dev suite including svn to Struts 1.3 (250MB 
> download) to get a head start on 1.3 (need to register to access).
> at www.infonoia.com community downloads section.
> 
> Best regards,
> 
> Wolfgang Gehner
> 
> 
> Matthias Wessendorf wrote:
> 
> >Hi all,  
> >
> >I have updated some apps to 1.3, that went pretty smooth :-)
> >(Thanks to the good documentation in wiki!!!)
> >
> >I saw in struts-config DTD that for <action> element now the
> >attributes "catalog" and "command" were introduced.
> >
> >I got a chain of commands to work (partly) w/ 1.3.
> >I now have two questions on working with chains instead of actions.
> >
> >#1
> >How do I *caculate* the navigation inside of my command?
> >Or do I need something extra? After my chain of commands was
> >executed, I saw a blank page (yes... no ActionForward found ;-))
> >
> >I have in struts-config something like that:
> ><action ...command="myChain" catalog="publishCat"...>
> >  <forward name="success" ...>
> ></action>
> >
> >Is there a "key" for the Context object, to tell him "success" must be
> >used for finding the ActionForward object ?
> >
> >#2
> >This is more a doubt on accessing formbeans in a command.
> >In my command I did the following to lookup my formBean object
> >(inside execute(Context cxt)):
> >FormularBean fb = (FormularBean) cxt.get(Constants.ACTION_FORM_KEY);
> >//org.apache.struts.chain.Constants
> >
> >this works pretty well, but now my doubt... is this the "right" way ?
> >
> >
> >Thanks for any hint :-)
> >
> >
> >Best Regards
> >Matthias Weßendorf
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> >For additional commands, e-mail: dev-help@struts.apache.org
> >
> >
> >  
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [Struts 1.3] Using Commons Chains instead of Action(s)

Posted by Michael Jouravlev <jm...@gmail.com>.
On 10/13/05, Wolfgang Gehner <ne...@infonoia.com> wrote:
> do:
>
> ActiionMapping mapping = (ActionMapping)
> context.get(org.apache.struts.chain.Constants.ACTION_CONFIG_KEY);
> ActionForward fw = mapping.findForward(forwardName);
>
> context.setForwardConfig(fw);
>
> Also see my Struts 1.3 dev suite (250MB download) at www.infonoia.com
> (you need to register).

Can you repackage it to, say 2MB or so, source code only?

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: [Struts 1.3] Using Commons Chains instead of Action(s)

Posted by Wolfgang Gehner <ne...@infonoia.com>.
do:

ActiionMapping mapping = (ActionMapping) 
context.get(org.apache.struts.chain.Constants.ACTION_CONFIG_KEY);
ActionForward fw = mapping.findForward(forwardName);

context.setForwardConfig(fw);

Also see my Struts 1.3 dev suite (250MB download) at www.infonoia.com 
(you need to register).
We wrapped the above in our own ActContext class which extends 
ServletActionContext and has context.setForward(forwardName)
We also wrote a DispatchCmd, similar to DispatchAction, but for 
commands, (so you have event handles like onSave(Act Context))

Also see our Struts 1.3 dev suite including svn to Struts 1.3 (250MB 
download) to get a head start on 1.3 (need to register to access).
at www.infonoia.com community downloads section.

Best regards,

Wolfgang Gehner


Matthias Wessendorf wrote:

>Hi all,  
>
>I have updated some apps to 1.3, that went pretty smooth :-)
>(Thanks to the good documentation in wiki!!!)
>
>I saw in struts-config DTD that for <action> element now the
>attributes "catalog" and "command" were introduced.
>
>I got a chain of commands to work (partly) w/ 1.3.
>I now have two questions on working with chains instead of actions.
>
>#1
>How do I *caculate* the navigation inside of my command?
>Or do I need something extra? After my chain of commands was
>executed, I saw a blank page (yes... no ActionForward found ;-))
>
>I have in struts-config something like that:
><action ...command="myChain" catalog="publishCat"...>
>  <forward name="success" ...>
></action>
>
>Is there a "key" for the Context object, to tell him "success" must be
>used for finding the ActionForward object ?
>
>#2
>This is more a doubt on accessing formbeans in a command.
>In my command I did the following to lookup my formBean object
>(inside execute(Context cxt)):
>FormularBean fb = (FormularBean) cxt.get(Constants.ACTION_FORM_KEY);
>//org.apache.struts.chain.Constants
>
>this works pretty well, but now my doubt... is this the "right" way ?
>
>
>Thanks for any hint :-)
>
>
>Best Regards
>Matthias Weßendorf
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>For additional commands, e-mail: dev-help@struts.apache.org
>
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org