Friday, November 9, 2012

Part 2 - Resource catalog, customization and personalization in Oracle WebCenter application

Part 2 - Resource catalog, customization and personalization in Oracle WebCenter application 

Part 2 - Resource catalog, customization and personalization in Oracle WebCenter application describes steps for configuring default resource catalog, creating and adding your own resource catalogs, how to use of PortalBundle.properties to define strings used in resource catalog

23. Default Resource Catalog

Run application. Login as weblogic/welcome1 or administrator1/welcome1

Note Edit link. This is enabled only for users in Administrators group. It is disabled for Guest. Where is this Edit link in jspx code? Well, it is pe:changeModeLink

Click Edit, Add Content

Pop up displays as shown. This is Default Resource Catalog
Figure 35


Default Resource Catalog contents are displayed from default-catalog.xml
Figure 36

24. Adding entries to Default Resource Catalog

If it is required to add an out-of-the-box task flow, e.g. RSS Viewer Task flow, to Default Resource Catalog, View > Resource Palette > My Catalogs > WebCenter Portal – Services Catalog > Task Flows. Right click RSS Viewer, click Show Catalog Reference
Figure 37


Select xml text and press Ctrl + C to copy selected text
Figure 38
               
Go to Source view of default-catalog.xml. Paste this copied text between
<contents xmlns="http://xmlns.oracle.com/adf/rcs/catalog"></catalog> tag
    <resource id="RSSViewerTaskFlow" name="RSS Viewer Task Flow"
              repository="application.classpath"
              path="rss-service-view.jar/ADF_TaskFlow/oracle+webcenter+rssviewer+view+jsf+fragments+RSSViewerTaskFlow.xml#RSSViewerTaskFlow"/>

name="RSS Viewer Task Flow" attribute is added within resource tag

Default Resource Catalog appears as below at runtime, on clicking Edit, Add Content
Figure 39

 25.  Adding your own Resource Catalog (example with out-of-the-box task flow)

1.       Right click catalogs under Portal > Web Content > oracle > webcenter > portalapp > catalogs. Select New
Figure 40

2.       Under Categories, expand Web Tier, select Portal, select Application Resource catalog
Figure 41

 3.       Click OK. Provide name e.g. rssViewer-catalog.xml
Figure 42

4.        Paste Resource Declaration text from Resource Catalog Reference in between <contents xmlns="http://xmlns.oracle.com/adf/rcs/catalog"></contents> tag (refer Figure) in Source view of rssViewer-catalog.xml
<contents xmlns="http://xmlns.oracle.com/adf/rcs/catalog"></catalog> tag
    <resource id="RSSViewerTaskFlow" name="RSS Viewer Task Flow"
              repository="application.classpath"
              path="rss-service-view.jar/ADF_TaskFlow/oracle+webcenter+rssviewer+view+jsf+fragments+RSSViewerTaskFlow.xml#RSSViewerTaskFlow"/>

name="RSS Viewer Task Flow" attribute is added within resource tag


5.       In RSSNewsFeeds.jspx, add property catalog="/oracle/webcenter/portalapp/catalogs/rssViewer-catalog.xml" to pe:pageCustomizable tag. Click arrow towards end of Page Customizable – Property Inspector > Advanced > Catalog to display Property Help of Catalog. This displays path to catalogs folder. Refer below image

Read text as hint to provide path to custom Resource Catalog /oracle/webcenter/portalapp/catalogs/SampleCatalog.xml for path, in below image
Figure 43

Contents of rssVierwer-catalog.xml appears as below at runtime, on clicking Edit, Add Content
Figure 44

Interesting fact
This has fallback mechanism. If you change catalog property of pe:pageCustomizable to catalog="/oracle/webcenter/portalapp/catalogs/rssViewer-catalog1.xml" – there is no such file. Hence at runtime, application fails to find rssViewer-catalog1.xml. So it loads Default Resource Catalog. Try it. So always add your Resource Declaration text from Resource Catalog Reference to contents tag of default-catalog.xml, besides adding your task flows there as well

26. Adding your own Resource Catalog (example with ADF component viz. af:goLink i.e. Hyperlink)

1.       Open default-catalog.xml in Design view. Expand Web Development node as shown. Select Hyperlink (or any component you wish to add to your Resource Catalog). Selecting Hyperlink will help you locate text to be copied from Source view, as that text would be selected in Source view as well
Figure 45

2.       Add new Resource Catalog, say externalLinks-catalog.xml

3.       Paste below text between <contents xmlns="http://xmlns.oracle.com/adf/rcs/catalog"></contents> tag
    <component id="link" visible="#{true}"
factoryClass="oracle.adf.rc.component.XmlComponentFactory">
      <attributes>
        <attribute attributeId="Title" value="LINK" isKey="true"/>
        <attribute attributeId="Description" value="LINK.DESCRIPTION"
                   isKey="true"/>
        <attribute attributeId="Subject" value="LINK.KEYWORDS" isKey="true"/>
        <attribute attributeId="IconURI"
                   value="/adf/webcenter/weblinks_qualifier.png"/>
      </attributes>
      <parameters>
        <parameter id="xml">
                <![CDATA[<cust:showDetailFrame xmlns:cust="http://xmlns.oracle.com/adf/faces/customizable"
                                        id="#" background="light"
                                        contentStyle="background-color:transparent;"
                                        displayHeader="false" showMinimizeAction="none"
                                        showResizer="never" stretchContent="false">
                    <f:attribute xmlns:f="http://java.sun.com/jsf/core"
                                 name="sdf_selection_rule" value="sdf_for_edit_mode_only"/>
                    <af:goLink id="#" text="#{componentExtensionBundle.LINK_TEXT}"                             xmlns:af="http://xmlns.oracle.com/adf/faces/rich"/>
                  </cust:showDetailFrame>
                ]]>
              </parameter>
      </parameters>
    </component>

4.       Switch to Design view
Figure 46

5.       Open PortalBundle.properties
Figure 47

 6.       In Design view of externalLinks-catalog.xml, select LINK
Figure 48

7.       You can add Title, Description from Resource Bundle. Add below lines to PortalBundle.properties and save it
TITLE=Add link
DESCRIPTION=Click + Add to add link


8.       Click magnifying glass icon next to Title to display Browse Classes. Pop up opens up as shown below
Figure 49

9.       Delete text in Display Value: (LINK is pre populated in Display Value when this pop up opens up) to display Keys that were added in properties file, in Matching Text Resources. Select TITLE, click Select. Similarly add Description. If you do not wish to use Resource Bundle, select Literal String from dropdown under Value Type column as shown below and type your own text in Display Value for particular row under Name column
Figure 50

externalLinks-catalog.xml gets modified as below
    <component id="link" visible="#{true}"
               factoryClass="oracle.adf.rc.component.XmlComponentFactory">
      <attributes>
        <attribute attributeId="Title" value="TITLE" isKey="true"
                   resourceBundle="portal.PortalBundle"/>
        <attribute attributeId="Description" value="DESCRIPTION" isKey="true"
                   resourceBundle="portal.PortalBundle"/>
        <attribute attributeId="Subject" value="" isKey="false"/>
        <attribute attributeId="IconURI"
                   value="/adf/webcenter/weblinks_qualifier.png" isKey="false"/>
      </attributes>
      <parameters>
        <parameter id="xml">
                <![CDATA[<cust:showDetailFrame xmlns:cust="http://xmlns.oracle.com/adf/faces/customizable"
                                        id="#" background="light"
                                        contentStyle="background-color:transparent;"
                                        displayHeader="false" showMinimizeAction="none"
                                        showResizer="never" stretchContent="false">
                    <f:attribute xmlns:f="http://java.sun.com/jsf/core"
                                 name="sdf_selection_rule" value="sdf_for_edit_mode_only"/>
                    <af:goLink id="#" text="Please enter link title here" targetFrame="_blank"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich"/>
                  </cust:showDetailFrame>
                ]]>
              </parameter>
      </parameters>
    </component>

af:goLink tag can be modified as
<af:goLink id="#" text="Please enter link title here" targetFrame="_blank"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich"/>

Tip
To obtain more properties that could be added to af:goLink tag, on any TestPage.jspx, drag drop Go Link component from Component Palette, press space bar within af:goLink tag

For e.g. in above af:goLink, I have added text="Please enter link title here”,  targetFrame="_blank". Because of this below is output displayed at runtime. Since rendered=”true” by default, Show Component is checked by default
Figure 51

10.   Add new JSF Page ExternalLinks.jspx containing below code
Important
Code is only for your reference. Avoid copying and pasting any code containing Oracle Composer components viz. Change Mode Button, Change Mode Link, Page Customizable, Layout Customizable, Panel Customizable, Show Detail Frame. Drag drop Oracle Composer components for them to function correctly
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
          xmlns:pe="http://xmlns.oracle.com/adf/pageeditor"
          xmlns:cust="http://xmlns.oracle.com/adf/faces/customizable">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <f:view>
    <af:document id="d1" title="External Links">
      <af:form id="f1">
        <af:pageTemplate viewId="/oracle/webcenter/portalapp/pagetemplates/pageTemplate_globe.jspx"
                         id="pt1">
          <f:facet name="content">
            <af:panelGroupLayout id="pgl1" layout="vertical">
              <af:panelGroupLayout id="pgl2" layout="horizontal">
                <af:outputText value="#{securityContext.userName}" id="ot1"/>
                <af:spacer width="10" height="10" id="s1"/>
                <pe:changeModeLink id="cml1"/>
              </af:panelGroupLayout>
              <pe:pageCustomizable id="pageCustomizable1"
                                   catalog="/oracle/webcenter/portalapp/catalogs/externalLinks-catalog.xml">
                <f:facet name="editor">
                  <pe:pageEditorPanel id="pep1"/>
                </f:facet>
                <pe:layoutCustomizable id="layoutCustomizable1"
                                       type="oneColumn">
                  <cust:panelCustomizable id="panelCustomizable1"/>
                  <f:facet name="contentA">
                    <cust:panelCustomizable id="panelCustomizable2"/>
                  </f:facet>
                  <f:facet name="contentB">
                    <cust:panelCustomizable id="panelCustomizable3"/>
                  </f:facet>
                </pe:layoutCustomizable>
              </pe:pageCustomizable>
            </af:panelGroupLayout>
          </f:facet>
        </af:pageTemplate>
      </af:form>
    </af:document>
  </f:view>
</jsp:root>

11.   Add entry of ExternalNews.jspx to pages.xml

External Links Resource Catalog appears as below at runtime, on clicking Edit, Add Content
Figure 52

27. Personalization

To test personalization log in as guest1/welcome1. Collapse any RSS news feed. Logout and login as guest2/welcome1. All panels would be in expanded form to guest2

28. References

 http://docs.oracle.com/cd/E23943_01/webcenter.1111/e10148/jpsdg_page_editor.htm#CHDGBFHA




To run application, right click login.jspx in Application Navigator, click run. Login as weblogic/welcome1 or administrator1/welcome1 to observe customization. Login as guest1/welcome1 or guest2/welcome1 to observer personalization

No comments:

Post a Comment