Sitemap customization within WebCenter Portal is a lot easier than it may seem.
Within web.xml the sitemap servlet is defined as per below.
Conveniently, there is also a method available to retrieve the default sitemap. This sitemap is generated from the default-navigation-model.xml.
import oracle.webcenter.portalframework.sitestructure.preference.PortalPreferences;
String siteMap = "";
siteMap = PortalPreferences.getInstance().getSiteMap();
As such all you need to do is perform a find and replace within the siteMap string in order to manipulate your result or return your own customized sitemap from the servlet.
A sample of the full servlet is below:
package test_portal.portal.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import oracle.webcenter.portalframework.sitestructure.preference.PortalPreferences;
public class SiteMapServlet extends HttpServlet {
transient ServletConfig config = null;
public void init(ServletConfig config) throws ServletException {
this.config = config;
super.init(config);
}
public void doGet(javax.servlet.http.HttpServletRequest httpRequest, javax.servlet.http.HttpServletResponse httpResponse) throws IOException {
httpResponse.setContentType("text/xml");
PrintWriter out = httpResponse.getWriter();
String siteMap = "";
siteMap = PortalPreferences.getInstance().getSiteMap();
siteMap = siteMap.replaceAll("/faces/testNav","http://sample.com");
siteMap = siteMap.replaceAll("/faces/home","http://sample.com/");
siteMap = siteMap.replaceAll("\\?wcnav.model=%2Foracle%2Fwebcenter%2Fportalapp%2Fnavigations%2Fdefault-navigation-model","");
siteMap = siteMap.replaceAll("</loc>","</loc> \r <changefreq>weekly</changefreq>");
out.println(siteMap);
out.close();
}
}
Showing posts with label SEO. Show all posts
Showing posts with label SEO. Show all posts
Tuesday, October 29, 2013
Friday, September 28, 2012
WebCenter Portal - Linking Between Navigation Models
A navigation model in WebCenter is primarily used for the navigation and navigational structure of a WebCenter portal application At a current clients site we ran into the issue of using multiple navigation models and linking to them without the context of another or the current navigation model.
After a lot of research and poking around with the framework I managed to figure out that WebCenter has an undocumented (I couldn't find the doco) method of allowing to you to provide the context of a navigation model through a query string in the URL.
If you tried to go to a URL in WebCenter and you go to the below you URL you will be linked to the root level id called home in the default navigation model. As such if your refer to an id in another navigation model you will receive a 404 error. However, if add the location of the navigation model as a wcnav.model query string it seems to find it's navigation context.
Default Navigation Model: http://127.0.0.1:7101/testapp/faces/home
Test2 Navigation Model: http://127.0.0.1:7101/testapp/faces/home?wcnav.model=/oracle/webcenter/portalapp/navigations/test2_navigationModel1
This opens alot of doors in terms of WebCenters URLs. As with a little effort allows for bookmarkable, SEO friendly URLs.
Subscribe to:
Posts (Atom)

