use of org.exoplatform.portal.webui.navigation.UIPortalNavigation in project gatein-portal by Meeds-io.
the class UINavigationPortlet method getChildrenAsJSON.
public JSONArray getChildrenAsJSON(String nodeURI) throws Exception {
WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
UIPortalNavigation uiPortalNavigation = getChild(UIPortalNavigation.class);
Collection<UserNode> childs = null;
UserNode userNode = uiPortalNavigation.resolvePath(nodeURI);
if (userNode != null) {
childs = userNode.getChildren();
}
JSONArray jsChilds = new JSONArray();
if (childs == null) {
return null;
}
MimeResponse res = context.getResponse();
for (UserNode child : childs) {
jsChilds.put(toJSON(child, res));
}
return jsChilds;
}
use of org.exoplatform.portal.webui.navigation.UIPortalNavigation in project gatein-portal by Meeds-io.
the class UISitemapPortlet method toJSON.
private JSONObject toJSON(TreeNode tnode, MimeResponse res) throws Exception {
UIPortalNavigation uiPortalNavigation = getChild(UIPortalNavigation.class);
JSONObject json = new JSONObject();
UserNode node = tnode.getNode();
String nodeId = node.getId();
json.put("label", node.getEncodedResolvedLabel());
json.put("hasChild", tnode.hasChild());
json.put("isExpanded", tnode.isExpanded());
json.put("collapseURL", uiPortalNavigation.url("CollapseNode", nodeId));
ResourceURL rsURL = res.createResourceURL();
rsURL.setResourceID(nodeId);
json.put("getNodeURL", rsURL.toString());
if (node.getPageRef() != null) {
NavigationResource resource = new NavigationResource(node);
NodeURL url = Util.getPortalRequestContext().createURL(NodeURL.TYPE, resource);
url.setAjax(isUseAjax());
json.put("actionLink", url.toString());
}
JSONArray childs = new JSONArray();
for (TreeNode child : tnode.getChildren()) {
childs.put(toJSON(child, res));
}
json.put("childs", childs);
return json;
}
use of org.exoplatform.portal.webui.navigation.UIPortalNavigation in project gatein-portal by Meeds-io.
the class UISitemapPortlet method getChildrenAsJSON.
private JSONArray getChildrenAsJSON(String nodeID) throws Exception {
WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
List<TreeNode> childs = null;
UIPortalNavigation uiPortalNavigation = getChild(UIPortalNavigation.class);
TreeNode tnode = uiPortalNavigation.getTreeNodes().findNodes(nodeID);
if (tnode != null) {
UserNode userNode = uiPortalNavigation.updateNode(tnode.getNode());
if (userNode != null) {
tnode.setExpanded(true);
tnode.setChildren(userNode.getChildren());
childs = tnode.getChildren();
}
}
JSONArray jsChilds = new JSONArray();
if (childs == null) {
return null;
}
MimeResponse res = context.getResponse();
for (TreeNode child : childs) {
jsChilds.put(toJSON(child, res));
}
return jsChilds;
}
Aggregations