Thursday, September 20, 2012

Creating announcement in webcenter page style and associating the forum id dynamically based on the custom attributes


When you create generic content in Webcenter spaces by adding content in the page Style. Users might want to customize different parameters. For instance in my previous blog we created an announcement in a page style. If users want to use the same style for different spaces and want to show announcements related to that particular space. We will try to achieve this by adding custom attribute in the space. These custom attributes will be unique for each space

got to space –> manage all settings.
go to Custom attributes tab.
Click on add attribute.

image

Give a name and value and click add.
image

image


Now to use it in the page style as in my previous blog
In the Page definition where we can change our code to get  the parent id value from our custom attribute.
<executables>
   <page viewId="#{WCAppContext.application.siteTemplatesManager.currentSiteTemplateViewId}" id="shellTemplateBinding" Refresh="ifNeeded"/>
<taskFlow id="announcementminiview1" taskFlowId="/oracle/webcenter/collab/announcement/view/taskflows/mini-view-definition.xml#announcement-mini-view" activation="deferred" xmlns="
http://xmlns.oracle.com/adf/controller/binding">
<parameters>
         <parameter id="parentId" value="#{spaceContext.currentSpace.metadata.customAttributes['MyforumId']}"/>
         <parameter id="expandedAnnouncements" value="5"/>
         <parameter id="hideToolbar" value="#{!WCSecurityContext.userInScopedRole['Moderator']}"/>
</parameters>  
</taskFlow>
</executables>


To access custom atribute use with the name of the custom attribute to get this value
#{spaceContext.currentSpace.metadata.customAttributes['MyforumId']}

How to add announcements in webcenter spaces page style so all pages created using this style will have the same announcements


Sometimes moderators of a space in webcenter prefer having announcements in all the pages that are the same. Instead of the user having to add the component in every page, we can create a page style which can have it in common.

Go to Administration –> Resources in web center spaces
Click on  Page Styles
Select a page Style you want to add a common announcement task flow. click edit and Edit Source

image

in the page add the below code in the place you want it .
<cust:panelCustomizable id="pc231">
                          <af:region value="#{bindings.announcementminiview1.regionModel}" id="r1"/></cust:panelCustomizable>


In the page Definition tab , Under the executables add the task flow tab as mentioned below. You can also pass the parameters for the task flow as required
<executables>
   <page viewId="#{WCAppContext.application.siteTemplatesManager.currentSiteTemplateViewId}" id="shellTemplateBinding" Refresh="ifNeeded"/>
     
<taskFlow id="announcementminiview1" taskFlowId="/oracle/webcenter/collab/announcement/view/taskflows/mini-view-definition.xml#announcement-mini-view" activation="deferred" xmlns="http://xmlns.oracle.com/adf/controller/binding">
      <parameters>
         <parameter id="parentId" value="${1}"/>
         <parameter id="expandedAnnouncements" value="5"/>
         <parameter id="hideToolbar" value="#{!WCSecurityContext.userInScopedRole['Moderator']}"/>
      </parameters>
   </taskFlow>
</executables>