Liferay portal object

Source: Internet
Author: User
Portal object
1. Request
The request types in the portal are action request and render request.
Therefore, the Portlet interface defines two methods to process different requests respectively.
Processaction (actionrequest request, actionresponse response) and render (renderrequest request, renderresponse response)
In a sense, the render method is similar to the service method in the servlet. The doview doedit dohelp method is similar to the doget dopost method.
A. portletrequest is divided into renderrequest and actionrequest, which are triggered by renderurl and actionurl respectively.
The actionurl is applicable to actual actions. For example, after a form is submitted, the persistent status changes, session changes, and perference changes.
Renderurl is usually used to process the porlet navigation.
Example of actionurl:
<%
Portleturl Pu = renderresponse. createactionurl ();
Pu. setparameter ("action", "login ");
%>
<Form name = "form1" method = "Post" Action = "<% = pu. tostring () %>">
Example of renderurl:
<%
Portleturl Pu = renderresponse. createrenderurl ();
Pu. setparameter ("page", number );
%>
<A href = "<% = pu. tostring () %>"> next page </a>
B. Processing Method of renderurl and actionurl
When the client request is triggered by a renderurl, the Portal Server will call the render methods of all porlet on the protal page.
When the client requests an actionurl, the Portal Server will call the processaction methods of all porlet on the page,
Then call the render method.
C. Scope of the parameter parameters of renderrequest and actionrequest
When the client requests an actionrequest, all parameter parameters must be obtained in the processaction method.
If you want to obtain this parameter in renderrequest, you must
String STR = Req. getparameter ("action ")
Response. setrenderparameter ("action" str)
2. Response object
There are two types of response objects: renderresponse and actionresponse, which respectively encapsulate the response information of the corresponding renderrequest and actionrequest.
Their parent class porletresponse has two methods, setporperty and getporperty, used to pass information to the portal container.

Actionresponse is mainly used to process the following functions:

A. Redirection
B. Change the window status and Portlet Mode
C. Pass the parameter to renderrequest.
Renderresponse mainly deals:
A. Set contenttype
B. Get the outputstream and writer objects to output the page content.
C. Buffering Buffer
D. Set the title of the Portlet, but it must be called before the Portlet output; otherwise, do not ignore it.
3. portletconfig object
Similar to the servletconfig object, the portletconfig object provides methods for accessing the Portlet initialization information and portletcontext object.
Unlike the servletconfig D object, the portletconfig object provides i18n support for resources such as the porlet title. You can set different resource
Bundle files are supported in multiple languages
4. Portal session
Portal sessions are divided into applicaton scope and Portlet scope:
A. The objects stored in sessions within the application scope are available for all the Portlet applications within the same portal.
B. objects stored in sessions within the scope of the porlet scope are only available for this porlet. Other Portlet instances are not available even in the same application.
5. Preference object
Preference objects are designed to customize user settings and help users customize displays and behaviors that meet user needs,
Some database functions can be replaced. It should be noted that the preference object is only used to access simple configuration information and cannot completely replace database applications.
The preference object uses a key value to access configuration information. You can save the required information in preference temporarily.
Example:
Portletpreference P = Req. getportletpreferences ();
P. setvalue ("username", "zhangzunwei ");
P. Store ();
Perference
This feature is used to access personalized information of users. Therefore, preference objects of different users cannot be shared.
You can configure preference information in the Portlet. xml file:
<Portlet-preferences>
<Preference>
<Name> username </Name>
<Value> zhangzunwei </value>
<Read-only> true </read-only>
</Preference>
</Portlet-preferences>
In addition, preferencesvalidator pairs can be used together to verify the preference of the Portlet before it is stored to ensure data stability.

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.