define fragments as database entities

Important Update

Starting with uPortal 4.0.4, JPA-managed (database backed) fragments are now the default option. For those versions, you can revert back to defining fragments in dlm.xml by following these directions in reverse.

You will need to create the dlm.xml file. There is an example of that in layoutContext.xml.

As an alternative to defining DLM fragments in dlm.xml, portal administrators may elect to enable the RDBMConfigurationLoader, which loads fragment definitions from the database via Hibernate and JPA. The major advantage of this approach is that it allows fragments to be added, removed, or change their audiences without a portal restart.

RDBMConfigurationLoader can be turned on by modifying layoutContext.xml.

Warning

Once you make this change, DLM will no longer read fragments from dlm.xml; you must define all your fragments in the database.

layoutContext.xml

Modify dlmConfigurationLoader bean, replacing:

uportal-war/src/main/resources/properties/contexts/layoutContext.xml
<bean id="dlmConfigurationLoader" class="org.jasig.portal.layout.dlm.LegacyConfigurationLoader">
 <property name="configurationFile" value="classpath:/properties/dlm.xml" />
</bean> 

with

uportal-war/src/main/resources/properties/contexts/layoutContext.xml
 <bean id="dlmConfigurationLoader" class="org.jasig.portal.layout.dlm.RDBMConfigurationLoader">
    <property name="configurationFile" value="classpath:/properties/dlm.xml" />
    <property name="fragmentDao" ref="fragmentDefinitionDao" />
</bean>
 
Importing Fragment Definitions

Now that you've enabled the RDBMConfigurationLoader, you'll need a way to get fragment definitions into the database. Import/Export provides support for these entities.

Use the following command to import a directory that contains .fragment-definition files:

>ant data-import -Ddir=<path.to.frag-def.dir>

The .fragment-definition.xml files support the same XML syntax as dlm.xml

Example fragment-definition File
<fragment-definition xmlns:dlm="http://org.jasig.portal.layout.dlm.config" script="classpath://org/jasig/portal/io/import-fragment-definition_v3-1.crn">
  <dlm:fragment name='Guests' ownerID='guest-lo' precedence='20'>
   <dlm:audience evaluatorFactory='org.jasig.portal.layout.dlm.providers.GuestUserEvaluatorFactory'/>
  </dlm:fragment>
</fragment-definition>
  • Setting the precedence attribute
    • Each fragment must also declare an integer precedence value. This value is used during merging of fragments to position elements contributed from different fragments. It is also used to determine which precedence elements can override a lower precedence. The higher the number the higher the precedence.

 

Additional References

Having problems with these instructions?

Please send us feedback at uportal-user@lists.ja-sig.org

Add Feedback content box here.....