Foren

HttpSession from doView Method

thumbnail
Nicolas Tamayo, geändert vor 11 Jahren.

HttpSession from doView Method

Junior Member Beiträge: 29 Beitrittsdatum: 03.10.12 Neueste Beiträge
Hi All.

i Developed a Portlet that loads a Objects List in the View.jsp and this List is retrieved without Portal Database.

my solution is Save the List as HttpSession Parameter, but the Issue is that i can't call the HttpSession Object in DoView.

how i can call this object in this method?

or other solution that allow me save the Object in the view.jsp init?

thanks and regards.
thumbnail
jelmer kuperus, geändert vor 11 Jahren.

RE: HttpSession from doView Method

Liferay Legend Beiträge: 1191 Beitrittsdatum: 10.03.10 Neueste Beiträge
You can use the portlet session : portletRequest.getPortletSession();

But what you are doing is almost certainly a bad idea emoticon
thumbnail
Nicolas Tamayo, geändert vor 11 Jahren.

RE: HttpSession from doView Method

Junior Member Beiträge: 29 Beitrittsdatum: 03.10.12 Neueste Beiträge
Thanks for your quick reply.

thank for your apreciation, do you provide me a best idea to this.

the requirement is load a list in search container, the list is loades in each refresg of page, this means that te data source can vary from one view to another.

thanks a lot for you quick reply.

Note: still i need call the HttpSession, because i have a Attribute that save in the session in Login Process, i need this attribute to make the trieve Object List process. this object List is the list that i want show in the searchContainer

regards.
thumbnail
David H Nebinger, geändert vor 11 Jahren.

RE: HttpSession from doView Method

Liferay Legend Beiträge: 14915 Beitrittsdatum: 02.09.06 Neueste Beiträge
You're making assumptions here that are not correct. The login is part of the ROOT web application, and therefore your 'attribute' would be stored in it's http session. Your plugins have their own web application, and therefore have their own session.

Your first problem is trying to store this in the http session. Since you didn't indicate what the attribute is, it would be either something the user selects during login or a value that you derive based upon the user. If it is the former, instead you should think about using the user expando fields to store the value with the user (therefore it would be available everywhere), if it is something you derive from the user, then just use the derivation at the time the query must occur.

Second, you should not be doing retrieves on refresh. Portlet refreshes can occur many times, even if your portlet doesn't change. Instead you only do the retrieve during the action phase, and the render phase just does the render. That way you are only retrieving when you should, rather than for unrelated refresh activity.

Basically the portal environment should not be treated as a servlet environment. Any time you try to treat it that way, you are bound to get things just wrong.
thumbnail
Nicolas Tamayo, geändert vor 11 Jahren.

RE: HttpSession from doView Method

Junior Member Beiträge: 29 Beitrittsdatum: 03.10.12 Neueste Beiträge
Hi David

regarding treating the portal environment like servlet envronment, may be right. this is because of lack of practice.

regarding Expando Fields, you can provide me a link or reference that contains information for this.?

Thanks, Thanks a lot for your reply!!
Regards.

Note: the HttpSession Attribute that is saved for the User; is saved from Custom Login Portlet that was Developed to done de Authentication, and actually i able of done the retrieve operation of this Attribute from doView Method that belong to other portlet.