Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to pass attributes while forwarding to an action

 
martin jose
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Martin,

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

Indu
 
Graham VMead
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Graham ,


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

Martin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic