http://www.cnblogs.com/Ivan-j2ee/archive/2012/07/26/2610173.html
This document explains the way to setup a portlet.
Entities Involved
- PortletCategory – Used to define category for portlets.
- PortalPortlet – All the information about a portlet is stored here.
- PortletPortletCategory – This associates the portlets with the logical categories.
- PortalPage – A portal page. Every Portal Page has a owner associated to it (userLoginId). To move a portlet from one Portal Page to another can be done
- If the logged in user is the owner of the portal page or
- If the portal page is a system page. (userLoginId="NA")
- PortalPageColumn – The number of the columns can be defined for a portal page.
- PortalPagePortlet – The portlets that belong to a portal page.
- PortalPageAndUserLogin – (View entity PortalPage + UserLoginSecurityGroup) - The portal pages that are accessible to a user if he belongs to certain security group.
- PortletAttribute – This defines all the attributes of a portlet. For example,to display a portlet,it needs a roleTypeId (attrName) = PLACING_CUSTOMER (attrName).
How To Setup
Here I am taking an example from OOTB implementation to show how do we setup a portlet.
The reference file here is PartyPortletData.xml Data preparation needs to be done as shown bellow this is all done for viewprofile page in partymgr:
Following is the first portlet with its all the associations and details:
@H_403_60@<PortletCategory portletCategoryId@H_403_60@="PROFILE" description@H_403_60@="Profiles"@H_403_60@/> @H_403_60@<PortalPortlet portalPortletId@H_403_60@="party" portletName@H_403_60@="Party Info" screenName@H_403_60@="Party" screenLocation@H_403_60@="component://party/widget/partymgr/ProfileScreens.xml" description@H_403_60@="General information about a person or party group" screenshot@H_403_60@="/images/portlets/party.png"@H_403_60@/> @H_403_60@<PortletPortletCategory portalPortletId@H_403_60@="party" portletCategoryId@H_403_60@="PROFILE"@H_403_60@/> @H_403_60@<PortalPage portalPageId@H_403_60@="PartyProfile" sequenceNum@H_403_60@="0" portalPageName@H_403_60@="Party Profile Portal Page" description@H_403_60@="Party profile page using flexible Portal technology" ownerUserLoginId@H_403_60@="_NA_"@H_403_60@/> @H_403_60@<PortalPageColumn portalPageId@H_403_60@="PartyProfile" columnSeqId@H_403_60@="00001" columnWidthPercentage@H_403_60@="50"@H_403_60@/> @H_403_60@<PortalPageColumn portalPageId@H_403_60@="PartyProfile" columnSeqId@H_403_60@="00002"@H_403_60@/><!-- no width in pixels or percent,use the rest of the space available --> @H_403_60@<PortalPagePortlet portalPageId@H_403_60@="PartyProfile" portalPortletId@H_403_60@="party" portletSeqId@H_403_60@="00001" columnSeqId@H_403_60@="00001" sequenceNum@H_403_60@="0"@H_403_60@/>
Screen Setup
(OFBiz Trunk)
Now following code works in the screen to have portlets in action:
Trace the screen "viewprofile" from /party/widget/partymgr/PartyScreens.xml. We need to set portalPageId in parameters and include generic screen PortalPageScreen from component://common/widget/CommonScreens.xml
Which is as follows(Reference commit in OFBiz trunk rev. 900156):
@H_403_60@<screen name@H_403_60@="PortalPageScreen"@H_403_60@> @H_403_60@<section@H_403_60@> @H_403_60@<actions@H_403_60@> @H_403_60@<entity-one entity-name@H_403_60@="PortalPage" value-field@H_403_60@="portalPage"@H_403_60@/> @H_403_60@<get-related value-field@H_403_60@="portalPage" relation-name@H_403_60@="PortalPageColumn" list@H_403_60@="portalPageColumns"@H_403_60@/> @H_403_60@<entity-and entity-name@H_403_60@="PortalPagePortletView" list@H_403_60@="portalPagePortlets"@H_403_60@> @H_403_60@<field-map field-name@H_403_60@="portalPageId" from-field@H_403_60@="portalPage.portalPageId"@H_403_60@/> @H_403_60@</entity-and@H_403_60@> @H_403_60@</actions@H_403_60@> @H_403_60@<widgets@H_403_60@> @H_403_60@<platform-specific@H_403_60@> @H_403_60@<html@H_403_60@><html-template location@H_403_60@="component://common/webcommon/portal/showPortalPage.ftl"@H_403_60@/></html@H_403_60@> @H_403_60@</platform-specific@H_403_60@> @H_403_60@</widgets@H_403_60@> @H_403_60@</section@H_403_60@> @H_403_60@</screen@H_403_60@>