| Your Rating: |
Thanks for voting! |
   
|
 |
Please Wait |
Results: |
   
|
6 |
rates |
Setting up a custom JCR Browser
Tree Views
Tree Views are used in Magnolia to display repository content. AdminCentral uses them to display groups, users, web pages and documents. The tree view is also used to provide the JCR Browser found under tools, which provides a raw view of the content in the repository.
View a Tree
To see how users interact with Trees, login to AdminCentral and click on Security in the main menu then on one of Groups or Users. Both of these are Tree Views although they may not look like it given the flat structure they display. Another example is of course the JCR Browser found under the Tools menu "JCR Browser(website)". This Tree view shows a different perspective on the website. Unlike the Tree view accessed from the main menu by clicking on Website, the JCR Browser version shows more info. While the Website tree view shows only mgnl:content, the JCR Browser tree show mgnl:content, mgnl:contentNode, and mgnl:nodeData.
Create a new JCR Browser
Setting up a new Tree view for a custom repository requires three steps. First you need a menu item to access the Tree view. Second, you need a definition of a tree for your menu item. Third, you may need a Tree configuration if you want to display custom node types.
Step One
To get started, create the menu item by copying the menu node at:
/modules/admininterface/config/menu/tools/websiteJCR
to:
/modules/admininterface/config/menu/tools/myJCR
Change the title, and change the onclick values.
- title = my menu item
- onclick = MgnlAdminCentral.showTree('my-tree');
Logout and login to update the menus. You should be able to see your new menu item under tools. Clicking on it should produce an error to the effect that the tree doesn't exist or isn't found. This is okay because we haven't defined that yet.
Step Two
Now create the new Tree defnition node called 'my-tree' based on the existing JCR Browser Tree defnition. Simply copy the existing website-jcr tree definition:
/modules/admininterface/trees/website-jcr
to:
/modules/admininterface/trees/my-tree
Note that the name of the tree needs to match the value provided in your menu item's onclick value.
Now edit the repository value referenced in this my-tree Tree definition to point at the repository in which you are interested. If you have configured your menu and tree under the modules/admininterface node, then you shouldn't even have to restart Magnolia. The new tree definition should be noticed through Repository Observation. But if it isn't simply restart.
Step Three
Unless your repository uses custom types you are done. If your repository contains custom node types, the tree won't display them, and there are a couple more steps to take.
For example if you try what has been outlined here on the users or groups repositories you should see nothing. This is because the ConfigTreeConfiguration used by the website tree sets you up to view only mgnl:nodeData, mgnl:contentNode, and mgnl:content. Which makes sense for the website repository, but not for the groups or users repositories. Neither of them contain such nodes.
As a developer this problem of nodetypes is easily fixed. Simply add you own node types by creating a subclass of ConfigTreeConfiguration and override the method:
prepareTree(Tree, boolean, HttpServletRequest)
for example:
public void prepareTree(Tree tree, boolean browseMode, HttpServletRequest
request)
{
super.prepareTree(tree,browseMode,request);
tree.addItemType("lxm:category");
tree.addItemType("lxm:offer");
}
The addItemType calls set your Tree up with the example to see nodes of my custom node types. Which shouldn't help you, but you can always replace them. Then you should be able to see any of the data you have stored in your custom repository.
nb: as from Magnolia 3.0.2 (or trunk), the jcr browser will be setup to use the new JcrBrowserTreeConfiguration class, which adds a bunch of potentially useful node types by default.
In its previous incarnation on JspWiki, this page was last edited on Feb 9, 2007 10:25:07 AM by GregoryJoseph
Other known authors include :