Sunday, June 23, 2013

Pretty URL for pages in Webcenter Portal with multiple navigational model

Scenario - There are multiple navigation models in the portal, and the requirement is to refer any page in any Navigation Model using pretty url.

How to do - So lets suppose our sample navigation model looks like this -

Just drag and drop the other navigation models inside the default navigation model,
now it will create a navigation reference inside the default navigation model.

If you run the application, the entire default-navigational-model will be iterated, so the navigation reference that is added will be visible. 

Suppose if there are 10 navigation reference, all of them will be visible which is not actually needed. If no reference is mentioned here , the pages in other navigation will not be accessible via pretty URL.

So to solve this , we can tweak the forEach loop which iterates the default navigational model , i will check for the node.title in render property of CommandLink so that the
navigation references wont render.

<af:forEach var="node" varStatus="vs"
                        items="#{navigationContext.defaultNavigationModel.listModel['startNode=/, includeStartNode=false']}">
              <af:subform id="pt_sfm1">
                <af:switcher id="pt_sw1"
                             facetName="#{(empty node.attributes['Target']) || (node.attributes['Target'] == '_popup') ? 'command' : 'golink'}">
                  <f:facet name="command">
                    <af:commandLink id="pt_cl1" text="#{node.title}"
                                    inlineStyle="font-size:small;#{node.selected ? 'font-weight:bold;' : ''}"
                                    disabled="#{not node.navigable}"
                                    clientComponent="#{node.attributes['Target'] == '_popup' ? true : false}"
                                    rendered="#{node.title !='Navigation2'}">

The navigation reference will not be rendered as a part of iteration and all the pages will be accessible via pretty url.

Now we can access any page using pretty URL in the portal:-)

Important - I assume the default-navigation-model.xml is the default Portal's navigation model in the adf-config.xml . If the default Portal's navigation model is different , then use that Navigation Model which is configured as the base .