Portlet Development (JavaEE Development Version)¶
Table of Contents
Summary¶
Screen Development (render cycle)
Screen to be displayed in the portlet is created. It can be switched by looking at mode or window status.Screen for the display mode is always necessary.Action Process (processAction cycle)
Process of data submitted from the portlet is created. Function container which was created is called an Action Handler, which
can be used by registering it on the Portlet Edit Screen.It is also possible to link with another portlet by setting Event.Event Process (processEvent cycle)
Receive Process for the event generated by another portlet is created. Function container which was created is called an Event Handler, which can be used by registering it on the Portlet Edit Screen.
Files that are created will vary depending on the lifecycle of portlet as below.
render mandatory JavaEE Development Model Screen. Main JSP and HelperBean. processAction optional Java class which implemented handleAction PortletActionHandler interface. processEvent optional Java class which implemented PortletEventHandler interface.
Portlet API¶
it is necessary to utilize the Portlet API.
PortalManager¶
jp.co.intra_mart.foundation.portal.common.PortalManager
Portlet Mode¶
Display Mode are unavailable.
Obtaining Portlet Mode¶
(ex.) PortletMode.VIEW, PortletMode.EDIT, PortletMode.HELP
javax.portlet.RenderRequest renderRequest = PortalManager.getRenderRequest(); javax.portletPortletMode portletMode = renderRequest.getPortletMode();
Window Status¶
Obtaining Window Status¶
(ex.) WindowState.NORMAL, WindowState.MAXIMIZED, WindowState.MINIMIZED
javax.portlet.RenderRequest renderRequest = PortalManager. getRenderRequest(); javax.portlet.WindowState windowState = renderRequest. getWindowState();
Screen Development (render cycle)¶
by the getParameter method of HttpServletRequest object.
RenderRequest, RenderResponse¶
RenderResponse object which are the dedicated objects for displaying portlet.
Obtaining RenderRequest and RenderResponse
RenderRequest renderRequest = PortalManager.getRenderRequest(); RenderResponse renderResponse = PortalManager.getRenderResponse();Page argument can be obtained by using HttpServletRequest object (which is accessed by [request] keyword in JSP) too so that it can
be shared by the normal Web pages.Obtaining Page Argument in JSP
<% RenderRequest renderRequest = PortalManager.getRenderRequest(); // value1 and value2 have the same value String value1 = request.getParameter("param1"); String value2 = renderRequest.getParameter("param1"); %>Current portlet mode and window status are obtained from RenderRequest.
Scope of RenderRequest¶
portal_cd Key of portal screen where portlet is placed. portalKind Portal type of portal screen where portlet is placed. Following values are obtained.
user User Portal group Group Portal In order to set the request parameters to the portlet, it is necessary to execute Action process or Event process.Request parameters that were once set will be valid during the session duration until the next Action process or Event process is executed.
ActionURL, RenderURL¶
displayed again after the process, submission to the following URLs would be necessary to communicate with the portlet container.
ActionURL URL to call Action function RenderURL URL to re-display Portal Screen They can be obtained by using PortalManager.
Obtaining ActionURL and RenderURL
PortletURL actionURL = PortalManager.createActionURL(); PortletURL renderURL = PortalManager.createRenderURL();
JSP
<% PortletURL actionURL = PortalManager.createActionURL(); %> <!-- Call Service with some Registration Process --> <form action="<%= actionURL.toString() %>" method="POST"> <!-- Value used in Registration Process --> <input type="text" name="param1" value=""> <input type="submit" value="Execute"> </form>
[portal/desktop] path is assigned to the display of portal screen.Therefore, portal screen can be re-displayed by submitting to the Service. However, since portal information cannot be
inherited in this case, please use the method shown above. Submission to the Action URL is the only possible way to call Action process.Please register Action Handler on the Portlet Administration Screen, and submit it to ActionURL on the presentation page.If Action Handler is undefined, Portal Screen will be simply re-displayed. ActionURL includes portal information, and data volume is large. Please specify POST for method.
How to Share Normal Screen and Portlet Screen¶
And then, the JSP page for the normal screen should load the common page by using include tag.
<Presentation Page of Normal Screen which is commonly used with the Portlet Screen>
<html> <head> <link src="sample.css" type="text/css"> </head> <body> <div> Header Display Information </div> <!-- Include Common Code --> <jsp:include page="sample/sample-portlet.jsp" flush="true"/> <div> Footer Display Information </div> </body> </html>
Action Process (processAction cycle)¶
Creation of Action Handler¶
Create Java class which implements PortletActionHandler interface, and define the function below.
(This Java class is called Action Handler.)
(ex.) sample.portal.SampleActionHandler.java
// 「PortletActionHandler」 Interface is implemented. public class SampleActionHandler implements PortletActionHandler { public Serializable handleAction(String portletCd, ActionRequest request, ActionResponse response) { // Obtain Request Argument String value = request.getParameter("param1"); // Set Event // In case event is sent to intramart portlet, use ImEvent object. // ImEvent.IM_QNAME is used for QName. ImEvent event = new ImEvent(); event.setEvent(value); response.setEvent(ImEvent.IM_QNAME, event); return null; } }
Action Handler may also use the function container created in Script Development Model which is used by render. Event can be generated by the return of following values.
- jp.co.intra_mart.foundation.portal.common.handler .ImEvent instance
- java.util.Map instance ・・・Event that has the pair value with Map key
- Others ・・・ judged as a character string. Event that has the same value with the key.
In order to generate the event to the IM Portlet, it is necessary to use ImEvent class or specify the key starting with ‘im_’.
Please refer to PortletActionHandler of [Portal API List] for detail.Register Action Handler to the Portlet
![]()
<Portlet New Registration Screen>
Place the Screen created in [Screen Development (render cycle)] on the portal screen, and Call Action Process from Portlet.
Screen is re-displayed after the execution of Action process.
![]()
<Portal Screen - Action Process>
ActionRequest, ActionResponse¶
RenderParameter Setting¶
be explicitly set if it is required.
(ex.) Setting of RenderParameter in processAction cycle
// In case Request Parameter is set response.setRenderParameter("param1", "value1"); // In case Request Parameter is deleted response.setRenderParameter("param2", null);(ex.) Use of RenderParameter in render cycle
String value = request.getParamter("param1");
PortletPreferences Setting¶
(ex.) Use of javax.portlet.PortletPreferences
// Obtaining PortletPreferences PortletPreferences preferences = request.getPreferences(); // Obtaining Information which was set in PortletPreferences String value = preferences.getValue("key1", "Default Value"); // Set Information to PortletPreferences. preferences.setValue("key1", "value1"); // Settle PortletPreferences. // If this process is not executed, information is not saved. preferences.store();
Event Setting¶
(ex.) Event setting in processEvent cycle
response.setEvent(eventId, eventValue);
Available Action Handler¶
intra-mart Accel Platform provides the Action Handler below as standard.
jp.co.intra_mart.foundation.portal.common.handler.DefaultPortletHandler¶
- “portlet.event.” + any character string
By doing it, the event below will be created.
Property Name Contents id arbitrary character string of request parameter key value request parameter value You can set multiple request parameters and generate multiple events.
jp.co.intra_mart.foundation.portal.common.handler.SetRenderParameterHandler¶
Event Process (processEvent cycle)¶
Action process of any portlet.
Creation of Event Handler¶
Create Java class which implements PortletEventHandler interface, and define the function below.
(This Java class is called Event Handler.)
(ex.) sample.portal.SampleEventHandler.java
// [PortletEventHandler] interface is implemented. public class SampleEventHandler implements PortletEventHandler { public Serializable handleEvent(String portletCd, EventRequest request, EventResponse response) { // Obtaining Event Object // Event object used between intramart portlets will be [ImEvent]. ImEvent event = (ImEvent) request.getEvent().getValue(); // Set request parameter which is used for screen display response.setRenderParameter(event.getEventId(), event.getEvent()); return null; } }
Event Handler can also use function container created in the Script Development Model used by render.
You can further generate the event by setting the return value.<*> Please be careful not to cause the loop in your design.Register Event Handler to the Portlet.
![]()
<Portlet New Registration Screen>
Place the screen created by [Screen Development (render cycle) ] and the portlet which can call the event created by
[Action Process (processAction cycle)] on the Portal Screen, and calls the Action porcess from the portlet that sets the event.Event Handler is executed by the Action process. Then, the screen will be re-displayed.
![]()
<Portal Screen - Event Process>
ImEvent Object¶
Property Name Type Value id String Event ID which is set in Action processIf omitted, character string [ImEvent] is set.value String Value of event which is set in Action processIt is obtained as a character string even when the object is set.source String Portlet code of the portlet which set the Event.
EventRequest, EventResponse¶
RenderParameter Setting¶
unless any special process is made.
(ex.) Setting of RenderParameter in processEvent cycle
// In case request parameter is set response.setRenderParameter("param1", "value1"); // In case request parameter is deleted response.setRenderParameter("param2", null);(ex.) Use of RenderParameter in render cycle
request.getParamter(eventId);
PortletPreferences Setting¶
(ex.) Use of java.portlet.PortletPreferences
// Obtaining PortletPreferences PortletPreferences preferences = request.getPreferences(); // Obtaining Information which was set in PortletPreferences String value = preferences.getValue("key1", "Default Value"); // Information is set in PortletPreferences. preferences.setValue("key1", "value1"); // Settle PortletPreferences. // If this process is not executed, information is not saved. preferences.store();
Event Setting¶
However, please be aware that doing the event process within the event process would cause performance degradation, and may possibly cause the event loop.
So, it should be implemented carefully.
(ex.) Event setting in processEvent cycle
response.setEvent(eventId, eventValue);
About [Important Notice] Portlet¶
- Category that shows the type of New Arrival Information
- Contents of New Arrival Information (Summary)
- Delivery Date
- Transition Information associated with the New Arrival Information (link)
Implement the Provider that obtains New Arrival Information.Information displayed in the new arrival portlet is obtained from the provider that implements the interface below.
Provider Interface for General New Arrival Information
jp.co.intra_mart.foundation.portal.general_purpose_portlet.provider.NewArrivedProvider
Password history management information is displayed in the [Important Notice] portlet using the provider below.Please refer to it when you implement your own provider.
Provider for Password History Management General New Arrival Information
jp.co.intra_mart.foundation.security.password.PasswordHistoryNewArrivedProvider
Please refer to [Portal API List] for details about provider interface and provider implementation. Define Provider Implementation.For information about the provider class implemented, the information below is defined in
<Storage Root>/public/storage/portal/system_notice.xml.<Provider Setting File>
Element
Description
new-arrived-portlet/sort
It defines if the obtained new arrival information is sorted by category.
new-arrived-portlet/provider/provider-class
It defines the implementation class of provider.
new-arrived-portlet/provider/init-param
It defines initialization parameter which is set to the provider class.
Shown below is the example of setting file description.
<system_notice.xml>
<new-arrived-portlet> <sort>true</sort> : : <provider> <provider-class> sample.SampleProvider </provider-class> <init-param> <param-name>param1</param-name> <param-value>hogehoge</param-value> </init-param> </provider> </new-arrived-portlet>You can register multiple providers, and display multiple new arrival information on 1 portlet.