aspose file tools*
The moose likes Struts and the fly likes how to pass attributes while forwarding to an action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to pass attributes while forwarding to an action" Watch "how to pass attributes while forwarding to an action" New topic
Author

how to pass attributes while forwarding to an action

martin jose
Greenhorn

Joined: Aug 10, 2005
Posts: 9
Hi guys,


In my application I have one calendar.do action. I can pass an attribte to it by calling it calendar.do?tgdate=1126247219084. In the action I am reading it using request.getParameter("tgdate"). It is working. Now my problem is, I have to come to this action from another action as a forward.

mapping.findForward("success"); where success is calendar.do

I this case how can I pass the date attribute. I tryed setting it as an attribure before forwarding.

request.setAttribute("tgdate",date);
return mapping.findForward("success");

but it is not working. Is there any alternative. I can't put the value in session beacuse I have to invoke it from simple HTML links also.

Hope some of you might have got this same problem. Please give me some tips

Thanx in advance
Martin
indu menon
Greenhorn

Joined: Sep 08, 2005
Posts: 1
Hi Martin,

Me too have the same problem. If you find a solution please let me know.

Indu
Graham VMead
Ranch Hand

Joined: Sep 22, 2003
Posts: 154
Hi Martin, Indu,

You can do it this way

In your Action Class

ActionForward theForward = actionMapping.findForward("success");
StringBuffer path=new StringBuffer(theForward.getPath());
path.append("?tgdate="+date);

return new ActionForward(path.toString());

There's also a utility class in the Scaffold ConvertUtils class
where you can use called ConvertUtils.addParam you will need to look this up on the net though.

Hope this helps

Graham
martin jose
Greenhorn

Joined: Aug 10, 2005
Posts: 9
Hi Graham ,


Thanks a lot. It is working perfectly. Thanks for your help.

Martin
 
Consider Paul's rocket mass heater.
 
subject: how to pass attributes while forwarding to an action