You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Martin Bunen <pe...@gmail.com> on 2005/08/16 01:11:19 UTC
obtain action path from a forward definition
Hi.
Assume I have the following in my struts-config.xml:
...
<action-mappings>
<action path="/FirstPage" name="FirstForm" type="com.mypkg.FirstAction" ...>
<forward name="forward to first page" .../>
</action>
<action path="/SecondPage name="SecondForm" type="com.mypkg.SecondAction" ...>
<forward name="forward to second page" .../>
</action>
</action-mappings>
Assuming I'm currently inside of com.mypkg.FirstAction.execute() method.
How can I obtain ActionConfig from the "forward to second page"
forward definition?
What I mean is that I know the forward name for the SecondPage action
mapping. I need to get to the path "/SecondPage".
Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: obtain action path from a forward definition
Posted by Martin Bunen <pe...@gmail.com>.
Ok, found a solution to my own problem:
...
moduleConfigImpl = (ModuleConfigImpl)mapping.getModuleConfig();
if (moduleConfigImpl != null)
{
actionConfigs = moduleConfigImpl.findActionConfigs();
if (actionConfigs != null)
{
for (ActionConfig actionConfig : actionConfigs)
{
forwardConfig = actionConfig.findForwardConfig(key);
...
On 8/15/05, Martin Bunen <pe...@gmail.com> wrote:
> My problem is that I don't know the path for the second action, but I
> do know the "forward to second page".
> I'm trying to implement a custom workflow engine where states are
> mapped to the <forward> definitions. This way I don't hardcode the
> form action in JSP but rather derive it from the state name.
>
>
> On 8/15/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
> > I think you'd have to know the path for the second action (/SecondPage
> > in this case)...
> >
> > mapping.getModuleConfig().findAcrionConfig("/secondPage").findForwardConfig("forward
> > to second page");
> >
> > Caveat: I haven't tried this. :)
> >
> > There is also a findForwardConfigs() method of ModuleConfig, so I
> > suppose if you didn't know the path you could call that, which returns
> > an array of ForwardConfig[] objects, then iterate over them calling
> > findForwardConfig() for the forward you want until you find it.
> >
> > However, I have to ask... why are you trying to do this in the first place?
> >
> > Frank
> >
> > Martin Bunen wrote:
> > > Hi.
> > > Assume I have the following in my struts-config.xml:
> > > ...
> > > <action-mappings>
> > > <action path="/FirstPage" name="FirstForm" type="com.mypkg.FirstAction" ...>
> > > <forward name="forward to first page" .../>
> > > </action>
> > >
> > > <action path="/SecondPage name="SecondForm" type="com.mypkg.SecondAction" ...>
> > > <forward name="forward to second page" .../>
> > > </action>
> > > </action-mappings>
> > >
> > > Assuming I'm currently inside of com.mypkg.FirstAction.execute() method.
> > > How can I obtain ActionConfig from the "forward to second page"
> > > forward definition?
> > > What I mean is that I know the forward name for the SecondPage action
> > > mapping. I need to get to the path "/SecondPage".
> > >
> > > Thanks.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> > >
> > >
> > > .
> > >
> >
> > --
> > Frank W. Zammetti
> > Founder and Chief Software Architect
> > Omnytex Technologies
> > http://www.omnytex.com
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: obtain action path from a forward definition
Posted by Martin Bunen <pe...@gmail.com>.
My problem is that I don't know the path for the second action, but I
do know the "forward to second page".
I'm trying to implement a custom workflow engine where states are
mapped to the <forward> definitions. This way I don't hardcode the
form action in JSP but rather derive it from the state name.
On 8/15/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
> I think you'd have to know the path for the second action (/SecondPage
> in this case)...
>
> mapping.getModuleConfig().findAcrionConfig("/secondPage").findForwardConfig("forward
> to second page");
>
> Caveat: I haven't tried this. :)
>
> There is also a findForwardConfigs() method of ModuleConfig, so I
> suppose if you didn't know the path you could call that, which returns
> an array of ForwardConfig[] objects, then iterate over them calling
> findForwardConfig() for the forward you want until you find it.
>
> However, I have to ask... why are you trying to do this in the first place?
>
> Frank
>
> Martin Bunen wrote:
> > Hi.
> > Assume I have the following in my struts-config.xml:
> > ...
> > <action-mappings>
> > <action path="/FirstPage" name="FirstForm" type="com.mypkg.FirstAction" ...>
> > <forward name="forward to first page" .../>
> > </action>
> >
> > <action path="/SecondPage name="SecondForm" type="com.mypkg.SecondAction" ...>
> > <forward name="forward to second page" .../>
> > </action>
> > </action-mappings>
> >
> > Assuming I'm currently inside of com.mypkg.FirstAction.execute() method.
> > How can I obtain ActionConfig from the "forward to second page"
> > forward definition?
> > What I mean is that I know the forward name for the SecondPage action
> > mapping. I need to get to the path "/SecondPage".
> >
> > Thanks.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
> >
> > .
> >
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: obtain action path from a forward definition
Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
I think you'd have to know the path for the second action (/SecondPage
in this case)...
mapping.getModuleConfig().findAcrionConfig("/secondPage").findForwardConfig("forward
to second page");
Caveat: I haven't tried this. :)
There is also a findForwardConfigs() method of ModuleConfig, so I
suppose if you didn't know the path you could call that, which returns
an array of ForwardConfig[] objects, then iterate over them calling
findForwardConfig() for the forward you want until you find it.
However, I have to ask... why are you trying to do this in the first place?
Frank
Martin Bunen wrote:
> Hi.
> Assume I have the following in my struts-config.xml:
> ...
> <action-mappings>
> <action path="/FirstPage" name="FirstForm" type="com.mypkg.FirstAction" ...>
> <forward name="forward to first page" .../>
> </action>
>
> <action path="/SecondPage name="SecondForm" type="com.mypkg.SecondAction" ...>
> <forward name="forward to second page" .../>
> </action>
> </action-mappings>
>
> Assuming I'm currently inside of com.mypkg.FirstAction.execute() method.
> How can I obtain ActionConfig from the "forward to second page"
> forward definition?
> What I mean is that I know the forward name for the SecondPage action
> mapping. I need to get to the path "/SecondPage".
>
> Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
>
> .
>
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: obtain action path from a forward definition
Posted by Martin Bunen <pe...@gmail.com>.
See, local forward definition (just as I described) does not work. If I call
mapping.findForwardConfigs() from inside of my FirstAction.execute()
method, I get only locally defined forwards, e.g. "forward to first
page". I would like to have a way to get to the SecondPage action
mapping from inside of FirstAction.execute() method.
I know that this works if I define forwards inside <global-forwards>
section, but I need to know if it's possible to get to the forwards in
the local <action-mappings> <action>... sections
Thanks!
On 8/15/05, Dave Newton <ne...@pingsite.com> wrote:
> Martin Bunen wrote:
>
> >Assuming I'm currently inside of com.mypkg.FirstAction.execute() method.
> >How can I obtain ActionConfig from the "forward to second page"
> >forward definition?
> >What I mean is that I know the forward name for the SecondPage action
> >mapping. I need to get to the path "/SecondPage".
> >
> >
> As I read it, you're asking two different questions.
>
> If you just want to go to /SecondPage you can either create a forward
> (local or global) to /SecondPage.do (or however you're mapping your
> Actions).
>
> Dave
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: obtain action path from a forward definition
Posted by Dave Newton <ne...@pingsite.com>.
Martin Bunen wrote:
>Assuming I'm currently inside of com.mypkg.FirstAction.execute() method.
>How can I obtain ActionConfig from the "forward to second page"
>forward definition?
>What I mean is that I know the forward name for the SecondPage action
>mapping. I need to get to the path "/SecondPage".
>
>
As I read it, you're asking two different questions.
If you just want to go to /SecondPage you can either create a forward
(local or global) to /SecondPage.do (or however you're mapping your
Actions).
Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org