How to get the ID and Portletid of an instance in Liferay

Source: Internet
Author: User
Tags session id



In the portlet, the request is divided into two types of Renderrequet and actionrequest and the portlet needs to get the instance ID when it is renderrequest to be taken, the following example


bool session_start(void); initialize session
bool session_destroy(void): Delete server-side session related files.
string session_id() The id of the current session
string session_name() The name of the currently accessed session, which is the name of the cookie that the client saves the session ID. Default
PHPSESSID.
array session_get_cookie_params() The details of the session associated with this session.
string session_cache_limiter() controls the client-side caching of pages that use the session
ini session_cache_expire() Control client cache time
bool session_destroy() Delete the file that saves session information on the server side
void session_set_cookie_params (int lifetime [, string path [, string domain [, bool
secure [, bool httponly]]]]) Set the details of the session associated with this session
bool session_set_save_handler (callback open, callback close, callback read, callback
write, callback destroy, callback gc) define the function of processing session, (not using the default method)
bool session_regenerate_id([bool delete_old_session]) assign a new session id


In the case of actionrequest is not the ID of the Portlet instance, actionrequest just the current page all the things passed in, in the middle after portletacition did the processing, It is not advisable to take portletid in Portletaction, but it has been provided in Liferay to allow us to get the instance ID code of the portlet in Actionrequest as follows


 ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest
		 .getAttribute(WebKeys.THEME_DISPLAY);
		 PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();
		System.out.println("portletDisplay---->"+portletDisplay.getInstanceId());
		System.out.println("portletDisplay getId---->"+portletDisplay.getId());
		System.out.println("portletDisplay getPortletName---->"+portletDisplay.getPortletName());


This allows you to take the corresponding Portlet instance ID that we need.






Where Webkeys.theme_display is the Liferay in the interface constant corresponding to the name is Theme_display






This article is a reprint of the article, the source of the article is http://www.cnblogs.com/edwardlauxh/archive/2010/03/26/1918614.html



How to get the ID and Portletid of an instance in Liferay


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.