This blog (my first one 😉 is about how to enhance the portal with a user customizable navigation node structure.
Similar to what the Portal Favorites provide, the user can now build up his own navigation tree, starting from an extra node added by this example's portal application. However, this example also enables inclusion of navigation structure subtrees. The developed portal app can be downloaded and used/built upon for future improvements. It is rather small sized (4 classes), so don't fear you'll get mad reading the code.
From a rather architectural point of view, this blog serves as a hint on how to use (or misuse) the Knowledge Management APIs to persist complex, user-dependent data structures. Typically, when it comes to persisting user-dependent data in a portal/web application, you'll get involved with coding JDBC or EJB far to soon. Especially EJB requires additional expertise and some modeling around, while you just want to get something working with little effort no matter how generic or reusable the result will be.
So let's just get first to the
I was thinking of initially, the choices I thought of and how to fulfill them, and afterwards I'll explain how it works and have a little user manual handed over to you.
First I thought of giving the user a chance to customize the navigation tree. So I had three sub tasks to think of:
Regarding task 1. and 2., there are, of course, lots of possibilities. As a good architect, already knowing your business classes (in this case, a tree structure) you'll first think of the persistence layer, I suspect.
1. Persistence. OK, let's list some programming approaches you could consider - JDBC, SQLJ, CMP Entity Beans, XML files stored in a DB, XML files stored in the KM, XML stored in the PCD, and, of course, POJOs stored as binary data in a database, the KM or the PCD. Aside from the POJOs, all the other approaches are rather too complex for just a little user dependent information, arent they? As I do not need to query over any two users datasets, I chose to store the data in the Knowledge Management user home directory (aka collection). Persistence of the tree structure is achieved by storing text and parsing the tree information from the text right before display.
This choice was made, I must admit, merely because of my final decision regarding the UI. If I had had the patience to create sort of UI for editing a tree structure, I'd chosen XML as the 'physical' persistence model.
Creating a UI that enables editing tree data structures in the portal. There are various possibilities I will not list here. With a focus on creating as little coding as possible, I reduced this blog's .par editing UI to just 'Editing ASCII text', reusing the KM editing facilities.
Adding the tree to the navigation. Only two possibilities are available here: Add a navigation connector to the portal navigation service or edit the portal content model using the PCM and/PCD APIs (By the way, the PCM/PCD portal applications also add a navigation connector to the navigation service, and this is why the top level nodes in the portal navigation are called roles most of the times.)
Finally, I had two viable approaches at hand:
So my final choice was the KM text resource based approach. And now, elaborating the
is rather short:
That's all. Still missing are the
Administrator:
End User:
Each line with trailing '+'s represents a tree node. The number of '+'s defines the tree node's level. Following the '+'s, you can write the node name that shows up in the portal, and a '|' sign followed by the link. The link may either be an absolute http address (like http://www.sap.com) or a navigation path (like pcd:portal_content/administrator/content_admin/content_admin_role/com.sap.portal.content_admin_ws/com.sap.portal.portal_content). If you omit the '|', the whole line content will be taken as link and for display.
+Google|http://www.google.com ++Yahoo|http://www.yahoo.com +SAP|http://www.sap.com ++SDN|http://www.sdn.sap.com ++Service Marketplace|http://service.sap.com ++Help Portal|http://help.sap.com +KM Content|pcd:portal_content/administrator/content_admin/content_admin_role/com.sap.portal.content_admin_ws/com.sap.km.AdminContent/com.sap.km.AdminContentExplorer and a link to another navigation file in the KM would look like this: ++TOC:othertree|/userhome/Administrator/wikistylenavigation2.txt
Download a .zip file containing a .par which in turn contains the source code from here (You need to be registered to SDN)