You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by CuteProgrammer <cu...@hotmail.com> on 2003/10/13 15:27:07 UTC

Dynamic ActionForwarding

Hi All...

 I'm not able to find the solution for this from last one month. Okay here goes my problem. Well i  in need to generate(dynamically) the ActionForwards based on data in the controller which has been extracted based on some user credentials. 

Eg  :

Lets assume we have a combo box  with some elements.  Based the the selection we need to take him to different pages. Lets say user selected some thing which has ID "101". Now what i did in cotroller is i extracted the data  from the database based on the selected id. then the url i need to forward will be  some thing like this  

                      /go.do?page=templateEdit

where  the value "templateEdit" is extracted from database based on the user selected id.

for solving this problem what i did is this. declared an actionforward like this

        <forward name="actionPage" path="/go.do?page={0}"/>

and in controller used the following code

<code>
            MessageFormat msgFormat = new MessageFormat(mapping.findForward("actionPage").getPath());        
            String path = msgFormat.format(new String[] {action});
            forward = new ActionForward(path);
</code>


what happens is first time it woks fine.But from the second time its still going to the first selected page. Can any one guess what is the problem.. or any other alternative way to do this.  one thing is i dont want to user new ActionForward("/go.do?page=templateEdit");

Thanks
Abhi