Karadous
Karadous

Reputation: 1635

how to share an object between multiple jsp pages in liferay?

I'm developing a liferay portlet. In this portlet I fetch the user information from database in portlet class and save them in a resultset. How can I share this resultset between portlet class and jsp pages?

Upvotes: 0

Views: 1263

Answers (2)

Mark
Mark

Reputation: 18827

It's recommended to hold the session thin, in this case I would put the data in the request.

java:

public class MyTestPortlet extends MVCPortlet {
    @Override
    public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
        User user = getCurrentUser(renderRequest);
        renderRequest.setAttribute("UserName", user.getScreenName());
        super.doView(renderRequest, renderResponse);
    }
...
}

jsp:

Hello ${UserName}!!!

Upvotes: 0

Anuj Balan
Anuj Balan

Reputation: 7729

Save the user objects in an arraylist and use session to save this arraylist. You can make it available throughout the portlet. Setting and getting is explained in this.

Example

Upvotes: 0

Related Questions