Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Philip Mueller
How to get ActionRequest in doView ?
June 8, 2013 7:08 AM
Answer

Philip Mueller

Rank: New Member

Posts: 10

Join Date: April 14, 2013

Recent Posts

In actionResponse you set the attribute to something, so you can get the parameter in view.jsp (if you forward to view.jsp) via request.getParamter(..). But I don't want to have logic in my jsp, so I would prefer to get the data in doView method in the mvc portlet. Indeed, there is no ActionRequest in doView(..). What should I do?
Sreeraj AV
RE: How to get ActionRequest in doView ?
June 10, 2013 12:14 AM
Answer

Sreeraj AV

Rank: Regular Member

Posts: 236

Join Date: April 26, 2010

Recent Posts

you can pass parameters from your action method and get the same thing in your render/doView method using getparamater() method.

try something like this
1actionResponse.setRenderParameter("studentId", studentId);


Philip Mueller:
In actionResponse you set the attribute to something, so you can get the parameter in view.jsp (if you forward to view.jsp) via request.getParamter(..). But I don't want to have logic in my jsp, so I would prefer to get the data in doView method in the mvc portlet. Indeed, there is no ActionRequest in doView(..). What should I do?
Philip Mueller
RE: How to get ActionRequest in doView ?
June 10, 2013 11:04 AM
Answer

Philip Mueller

Rank: New Member

Posts: 10

Join Date: April 14, 2013

Recent Posts

Thanks for answer. So if I do that, can I get the parameter in doView like this:
1
2public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
3{
4String studentId= renderRequest.getParameter("studentId")
5}
Sreeraj AV
RE: How to get ActionRequest in doView ?
June 10, 2013 9:53 PM
Answer

Sreeraj AV

Rank: Regular Member

Posts: 236

Join Date: April 26, 2010

Recent Posts

ya.. i think so...

u can use liferay specific api's to get parameter from request. it's a better way to get parameter values..

1
2
3String StudentId= ParamUtil.getString(renderRequest, "studentId");
4or
5long StudentId= ParamUtil.getLong(renderRequest, "studentId")


Philip Mueller:
Thanks for answer. So if I do that, can I get the parameter in doView like this:
1
2public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
3{
4String studentId= renderRequest.getParameter("studentId")
5}
Philip Mueller
RE: How to get ActionRequest in doView ?
June 11, 2013 6:48 AM
Answer

Philip Mueller

Rank: New Member

Posts: 10

Join Date: April 14, 2013

Recent Posts

Thanks for Answer.
Sreeraj AV:
ya.. i think so...

u can use liferay specific api's to get parameter from request. it's a better way to get parameter values..

Why is this class ParamUtil better?
Sreeraj AV
RE: How to get ActionRequest in doView ?
June 18, 2013 3:27 AM
Answer

Sreeraj AV

Rank: Regular Member

Posts: 236

Join Date: April 26, 2010

Recent Posts

It will handle typecasting and default value initialization.. Parameters are always of type String, we may have to type cast to other types depending requirement.

Philip Mueller:
Thanks for Answer.
Sreeraj AV:
ya.. i think so...

u can use liferay specific api's to get parameter from request. it's a better way to get parameter values..

Why is this class ParamUtil better?
Sandip Patel
RE: How to get ActionRequest in doView ?
June 18, 2013 6:06 AM
Answer

Sandip Patel

Rank: Regular Member

Posts: 195

Join Date: January 4, 2011

Recent Posts

Hi,

You can set parameter or object or object list in Action method as below.

actionRequest.setAttribute("Message",message);

And get in doView method as below.

renderRequest.getAttribute("Message");
Philip Mueller
RE: How to get ActionRequest in doView ?
June 18, 2013 8:07 AM
Answer

Philip Mueller

Rank: New Member

Posts: 10

Join Date: April 14, 2013

Recent Posts

Thanks all for answer. emoticon