Search in sources :

Example 1 with UIPortalNavigation

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;
}
Also used : MimeResponse(javax.portlet.MimeResponse) WebuiRequestContext(org.exoplatform.webui.application.WebuiRequestContext) UserNode(org.exoplatform.portal.mop.user.UserNode) JSONArray(org.json.JSONArray) UIPortalNavigation(org.exoplatform.portal.webui.navigation.UIPortalNavigation)

Example 2 with UIPortalNavigation

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;
}
Also used : JSONObject(org.json.JSONObject) TreeNode(org.exoplatform.portal.webui.navigation.TreeNode) UserNode(org.exoplatform.portal.mop.user.UserNode) JSONArray(org.json.JSONArray) UIPortalNavigation(org.exoplatform.portal.webui.navigation.UIPortalNavigation) NavigationResource(org.exoplatform.web.url.navigation.NavigationResource) NodeURL(org.exoplatform.web.url.navigation.NodeURL) ResourceURL(javax.portlet.ResourceURL)

Example 3 with UIPortalNavigation

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;
}
Also used : TreeNode(org.exoplatform.portal.webui.navigation.TreeNode) MimeResponse(javax.portlet.MimeResponse) WebuiRequestContext(org.exoplatform.webui.application.WebuiRequestContext) UserNode(org.exoplatform.portal.mop.user.UserNode) JSONArray(org.json.JSONArray) UIPortalNavigation(org.exoplatform.portal.webui.navigation.UIPortalNavigation)

Aggregations

UserNode (org.exoplatform.portal.mop.user.UserNode)3 UIPortalNavigation (org.exoplatform.portal.webui.navigation.UIPortalNavigation)3 JSONArray (org.json.JSONArray)3 MimeResponse (javax.portlet.MimeResponse)2 TreeNode (org.exoplatform.portal.webui.navigation.TreeNode)2 WebuiRequestContext (org.exoplatform.webui.application.WebuiRequestContext)2 ResourceURL (javax.portlet.ResourceURL)1 NavigationResource (org.exoplatform.web.url.navigation.NavigationResource)1 NodeURL (org.exoplatform.web.url.navigation.NodeURL)1 JSONObject (org.json.JSONObject)1