![]() ![]() ![]() ![]() ![]() ![]() |
The steps listed in this chapter are provided for your information; they are not required.
The portlets provided with the JSR-168 Consumer can be customized. To customize the existing portlets, follow the steps below:
servlets
, servlet-mappings
, context listener
, and tag libraries
. Use ptjsr168/1.1/devkit/WEB-INF/web.xml as a template. Elements must be added in the proper order, or the application will not start. See your application server documentation for the required ordering of elements in the web.xml document.
The default installation includes a WEB-INF directory for creating new portlet applications in ptjsr168/1.1/devkit/. To create an application from this directory, follow the instructions below:
The sample portlets in the JSR-168 Consumer package do not require shared sessions, but it is a best practice to configure shared sessions since the JSR-168 spec requires that sessions are shared per context.
Note: | The JSR-168 Consumer portlets cannot be configured to share sessions in versions of the portal prior to 6.0. |
To configure support for shared sessions, complete the steps below.
To add Tag Library support, add the following line to the web.xml file after servlet-mappings
and session-config
:
<taglib>
<taglib-uri>http://java.sun.com/portlet</taglib-uri>
<taglib-location>/WEB-INF/lib/jsr168tags.jar</taglib-location>
</taglib>
Note: | Make sure the jsr168tags.jar in the ptjsr168/1.1/devkit/WEB-INF/lib directory is added to the WEB-INF/lib directory. |
Follow the steps below to build any modified stylesheets.
SSL is used in the PortletURL call setSecure()
, and in the transport-guarantee
element of the security-constraint
element of portlet.xml.
To use SSL, open the jsr168.properties file in <PT_HOME>/ptjsr168/1.1/settings/config and set the appropriate values for httpport
and httpsport
. SSL must be enabled on the application server and a valid certificate must be installed. If you use a transport-guarantee
in portlet.xml, the portlet will redirect to the configured SSL port in jsr168.properties.
For both setSecure()
and transport-guarantee
, make sure to include the full SSL address up to the war file name in the gateway space (e.g., https:my_server:7002/my_war).
By default, the JSR-168 Consumer does not use the values from the application server for the security-related calls getRemoteUser()
, getUserPrincipal()
, and isUserInRole()
. Instead, it uses the logged-in portal user for getRemoteUser()
and getUserPrincipal()
, and activity rights for isUserInRole()
. Only the activity rights configured on the Advanced Settings page of the Web Service object are examined for isUserInRole()
.
To use the application server values for these methods, open the jsr168.properties file in <PT_HOME>/ptjsr168/1.1/settings/config and change the portalRemoteUser key to false. Changes will take effect when you restart your application server.
Note: | The application server will always return null for getRemoteUser() and getUserPrincipal() unless the user has logged into the application server. |
To access User Information settings from the portal, follow the steps below.
<user-attribute>
<description>User Phone</description>
<name>user.business-info.telecom.telephone.number</name>
</user-attribute>
If a user attribute is not defined in the portlet.xml file, it will not be read.
user.business-info.telecom.telephone.number=phone
The first value is the name used by the JSR168 Consumer; the second value is the name of the User Information property in the portal.
To complete the example and view the User Information in a portlet, follow the steps below:
String phone = (String) map.get("user.business-info.telecom.telephone.number");
Add the following to display in the jsp page:
phone is <%=phone%>
To display a page in edit mode, add edit to the action of the form as shown below. (For a complete example, see IncludePortletEdit.jsp, shipped with PtPortletContainer.)
<form name="form1" method="post" action=<portlet:actionURL portletMode="edit"/>>
To close the window, set the mode back to view in processAction
in the portlet, as shown below.
public final void processAction(ActionRequest req, ActionResponse res) throws PortletException, IOException
{
//do whatever processing is needed for multiple pages
//when processing is done, set the mode back to view
res.setPortletMode(PortletMode.VIEW);
}
![]() ![]() ![]() |