Planned maintenance is scheduled for the week of June 15th - the exact date and time will be announced soon.
See More Details
Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
renderRequest getAttribute in jsp does not update as in doView in portlet
Dear all,
I am trying to send dynamic String values from the doView method into the view.jsp. This is the code in doView:
And this is how I get it from the GraphEditorPortlet_view.jsp
But, everytime I do a post and a doView I always get the same number even if it get printed changed in the doView method.
Any hints?
Kind regards,
Eva.
I am trying to send dynamic String values from the doView method into the view.jsp. This is the code in doView:
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
System.out.println("doView()...");
request.setAttribute("test", Math.random());
System.out.println(request.getAttribute("test"));
response.setContentType("text/html");
PortletRequestDispatcher dispatcher =
getPortletContext().getRequestDispatcher("/WEB-INF/jsp/GraphEditorPortlet_view.jsp");
dispatcher.include(request, response);
}
And this is how I get it from the GraphEditorPortlet_view.jsp
<%=renderRequest.getAttribute("test") %>
But, everytime I do a post and a doView I always get the same number even if it get printed changed in the doView method.
Any hints?
Kind regards,
Eva.
Hi Eva,
It should work. I am attaching a small portlet called AttributePortlet in which i have set attribute in doView and reading the same in view.jsp.
And I would suggest you to use MVCPortlet so that you dont have to worry about dispatching and stuff.
Thanks.
It should work. I am attaching a small portlet called AttributePortlet in which i have set attribute in doView and reading the same in view.jsp.
And I would suggest you to use MVCPortlet so that you dont have to worry about dispatching and stuff.
Thanks.
Attachments:
Dear Mayur,
thank you for your reply. In my case the static attribute setting is working but it is not getting updated when doView() method is re-called after a POST call. I don't think moving to MVCPortlet would solve the issue.
Any other hints?
Kind regards,
Eva.
thank you for your reply. In my case the static attribute setting is working but it is not getting updated when doView() method is re-called after a POST call. I don't think moving to MVCPortlet would solve the issue.
Any other hints?
Kind regards,
Eva.
Community
Company
Feedback