Saturday, April 12, 2014

PreferenceBean in Webcenter - Store Custom Constants

Tip - There are multiple ways to store constants outside the context of application such as properties file, Database ,LDAP or MDS etc. There is one more simple way in webcenter where we could have it stored which is  preferences in adf-config.xml.

 <portal:adf-portal-config>
    <portal:preferences>
      <portal:preference id="oracle.webcenter.portalapp.navigation.model"
                         desc="Default Navigation Model"
                         value="/oracle/webcenter/portalapp/navigations/default-navigation-model.xml"
                         resourceType="navigation" display="true"/>
      <portal:preference id="oracle.webcenter.portalapp.resourcecatalog"
                         desc="Default Resource Catalog"
                         value="/oracle/webcenter/portalapp/catalogs/default-catalog.xml"
                         resourceType="ResourceCatalog" display="true"/>
      <portal:preference id="oracle.webcenter.portalapp.pagetemplate.pageTemplate"
                         desc="Default Page Template"

                         value="/oracle/webcenter/portalapp/
                         ...........
                         ...........

These preferences are used by in webcenter to store the default navigations,resource catalog etc which can be accessed anywhere in the portal using preference bean 

Eg : Default Skin - #{preferenceBean.defaultPortalSkin}
         Default Template -  #{preferenceBean.defaultPageTemplate}

These preferences can also be used to store custom constants that can be used anywhere in the application and again as we store this in adf-config.xml which is editable through MDS, all these constants can be changed at runtime as needed:-)

Eg : Sample preferences in Adf-Config.xml








ELs to access this preference -
   
#{preferenceBean.portalAdfConfigMap.configMap['sampleConstant'].id}
#{preferenceBean.portalAdfConfigMap.configMap['sampleConstant'].desc}
#{preferenceBean.portalAdfConfigMap.configMap['sampleConstant'].value}
#{preferenceBean.portalAdfConfigMap.configMap['sampleConstant'].resourceType}
                        













Hope this helps :-)

No comments:

Post a Comment