I'm trying to dynamically create a panel to navigate to a newly created
space. Then I want to put the panel in the left column of Main.WebHome.
This code is how I thought it would work but it doesn't seem like you put
Panel objects in Panels.WebHome and I haven't been able to figure out where
they should be put. If anyone knows I would appreciate knowing
XWikiDocument panelsDoc =
context.getWiki().getDocument("Panels.WebHome", context);
BaseObject bobj = panelsDoc.newObject("Panels.PanelClass", context);
//create a panel
String panelName = spaceName+"Pnl";
bobj.setStringValue("name", panelName);
bobj.setStringValue("type", "view");
bobj.setStringValue("description", "Dynamic Panel for " +
spaceName);
//the content of the panel - Note all quotes are escaped
bobj.setStringValue("category", "Navigation");
String content = "#panelheader('" + spaceName + "Links')" +
" * [Home>" + spaceName + ".WebHome]" +
" <p
style=\"font-size:0.75em;padding-left:8px;\">
\"$xwiki.getDocument(\"Panels." (Edit this panel) </p>" +
" #panelfooter()";
bobj.setStringValue("context", content);
context.getWiki().saveDocument(panelsDoc,
context.getMessageTool().get("core.comment.createdUser"), context);
//add to left panel list
XWikiDocument prefsDoc =
context.getWiki().getDocument("XWiki.XWikiPreferences", context);
BaseObject prefsObj = prefsDoc.getObject("XWiki.XWikiPreferences");
String csvLeftPanelList = prefsObj.getStringValue("leftPanels");
csvLeftPanelList = csvLeftPanelList + ",Panels."+panelName;
prefsObj.setStringValue("leftPanel", csvLeftPanelList);
context.getWiki().saveDocument(prefsDoc,
context.getMessageTool().get("core.comment.createdUser"), context);
So, as I mentioned not sure where or how to add the created Panel any help
would be appreciated.
Thanks
Glenn Everitt
--
View this message in context:
http://www.nabble.com/How-can-I-dynamically-create-a-panel--tp16406339p1646…
Sent from the XWiki- Dev mailing list archive at
Nabble.com.