0

I am trying to set an attribute of type list in a class and getting the attribute from the class to jsp by using following:

  1. First setting the attribute by using

    actionRequest.setAttribute("SEARCH_RESULT",result);

  2. For getting the object using the following

    request.getAttribute("SEARCH_RESULT");

But the above code always produces a null, why?

Uma Kanth
  • 5,659
  • 2
  • 20
  • 41
Saleem Khan
  • 339
  • 3
  • 16
  • 1
    This is unfortunatelly not possible due to Portlet spec. Action request and render requests are independent servlet requests (there is usually a HTTP redirect between them). You need to use flash scope (i.e. temporary session attribute) or pass your value via render paramters (http://portals.apache.org/pluto/portlet-2.0-apidocs/javax/portlet/StateAwareResponse.html#setRenderParameter%28java.lang.String,%20java.lang.String%29) – Pavel Horal Jun 04 '14 at 14:06
  • thanks for the comment can u please show me example of flash scope – Saleem Khan Jun 05 '14 at 05:04
  • setRenderParameter takes string as argument but i want to pass an object – Saleem Khan Jun 05 '14 at 05:08
  • There is another possibility -> http://stackoverflow.com/questions/13416157/passing-object-list-from-the-action-to-the-render-phase . Will mark this as duplicate. – Pavel Horal Jun 05 '14 at 07:19

1 Answers1

1

Use renderRequest.getAttribute(--)

Please have below links for more details

Liferay MVC Portlet Development

Meera Prince
  • 177
  • 3