9 abr 2013

WebCenter Spaces, navigation from one space to another space specifiying the destination path

Recently on a project we have the requirement of jumping from a Space to another one, but not the landing page.

This is the hierarchy and the desired navigation.






By default you can access to SpaceA with this URL: http://server/webcenter/spaces/spaceA

To access to second space the URL is http://server/webcenter/spaces/spaceB

Inside of SpacesB if you try to move to a "detail page" you can use http://server/webcenter/faces/news/detail because the navigation of the Space is the "default navigation" stored in memory.

Now imagine you're on SpaceA "home page", if you try to move to "detail page" of SpaceB you will get an error of 404 page not found.





This is produced because your current navigation is the default navigation defined in SpaceA.

To bypass this problem, we need to read the "default navigation" of SpaceB and create the correct link to the page.

First, we need the path of the "default navigation" of SpaceB, to get this value, we have to log as space administrator and go to the tab called "Resources".

Go to: http://server/webcenter/spaces/spaceB/admin

Select the correct resource and click "Edit Properties".


You will see a popup similar to this one, copy the value of the "Metadata File" clicking on "more" icon.





Now we have all needed information. It's time to create a "<af:goLink>" from one space to another.

Check this code:
<af:golink destination="#{navigationContext.navigationModel['/oracle/webcenter/siteresources/scopedMD/s8195d183_d2b1_4c90_b0fa_b541d2031f79/navigation/gsrbe2d4c14_2b20_4e1b_94aa_cc1930641d4e/default-navigation.xml'].node['news/detail'].goLinkPrettyUrl}" id="gl1">
</af:golink>


This is the syntax of the Expression Language (EL) used:

 #{navigationContext.navigationModel['<path to xml>'].node['<hierarchy>'].goLinkPrettyUrl}

This <af:goLink> will produce a HTML output like this:

http://server/webcenter/faces/news/detail?wc.contextURL=/spaces/spaceA&&wcnav.model=%2Foracle%2Fwebcenter%2Fsiteresources%2FscopedMD%2Fs8195d183_d2b1_4c90_b0fa_b541d2031f79%2Fnavigation%2Fgsrbe2d4c14_2b20_4e1b_94aa_cc1930641d4e%2Fdefault-navigation

 Souces:
  • WebCenter Developer's guide (link)