Search in sources :

Example 6 with ResourceURL

use of javax.portlet.ResourceURL 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 7 with ResourceURL

use of javax.portlet.ResourceURL in project gatein-portal by Meeds-io.

the class BasePartialUpdateToolbar method toJSON.

protected JSONObject toJSON(UserNode node, String navId, MimeResponse res) throws Exception {
    JSONObject json = new JSONObject();
    String nodeId = node.getId();
    json.put("label", node.getEncodedResolvedLabel());
    json.put("hasChild", node.getChildrenCount() > 0);
    json.put("isSelected", nodeId.equals(getSelectedNode().getId()));
    json.put("icon", node.getIcon());
    ResourceURL rsURL = res.createResourceURL();
    rsURL.setResourceID(getResourceIdFromNode(node, navId));
    json.put("getNodeURL", rsURL.toString());
    if (node.getPageRef() != null) {
        NavigationResource resource = new NavigationResource(node);
        NodeURL url = Util.getPortalRequestContext().createURL(NodeURL.TYPE, resource);
        json.put("actionLink", url.setAjax(false).toString());
    }
    JSONArray childs = new JSONArray();
    for (UserNode child : node.getChildren()) {
        childs.put(toJSON(child, navId, res));
    }
    json.put("childs", childs);
    return json;
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) UserNode(org.exoplatform.portal.mop.user.UserNode) NavigationResource(org.exoplatform.web.url.navigation.NavigationResource) NodeURL(org.exoplatform.web.url.navigation.NodeURL) ResourceURL(javax.portlet.ResourceURL)

Example 8 with ResourceURL

use of javax.portlet.ResourceURL in project gatein-portal by Meeds-io.

the class UICaptcha method processRender.

public void processRender(WebuiRequestContext context) throws Exception {
    RenderResponse resp = context.getResponse();
    // 
    ResourceURL url = resp.createResourceURL();
    // context.getPortalContextPath() + "/captcha?v=" + Calendar.getInstance().getTimeInMillis()
    String random = "&v=" + Calendar.getInstance().getTimeInMillis();
    context.getWriter().write("<div id='" + getId() + "'><img src=\"" + url.toString() + random + "\" alt=\"Captcha image for visual validation\" /><br/>");
    super.processRender(context);
    context.getWriter().write("</div>");
}
Also used : RenderResponse(javax.portlet.RenderResponse) ResourceURL(javax.portlet.ResourceURL)

Example 9 with ResourceURL

use of javax.portlet.ResourceURL in project social by Meeds-io.

the class UIIntranetNotificationsPortlet method buildResourceURL.

protected String buildResourceURL(String key) {
    try {
        WebuiRequestContext ctx = WebuiRequestContext.getCurrentInstance();
        MimeResponse res = ctx.getResponse();
        ResourceURL rsURL = res.createResourceURL();
        rsURL.setResourceID(key);
        return rsURL.toString();
    } catch (Exception e) {
        return "";
    }
}
Also used : MimeResponse(javax.portlet.MimeResponse) WebuiRequestContext(org.exoplatform.webui.application.WebuiRequestContext) ResourceURL(javax.portlet.ResourceURL)

Example 10 with ResourceURL

use of javax.portlet.ResourceURL in project WebproxyPortlet by uPortal-Project.

the class URLRewritingFilter method createResourceUrl.

protected String createResourceUrl(final RenderResponse response, final String url) {
    final ResourceURL resourceUrl = response.createResourceURL();
    resourceUrl.setParameter(HttpContentServiceImpl.URL_PARAM, url);
    return resourceUrl.toString();
}
Also used : ResourceURL(javax.portlet.ResourceURL)

Aggregations

ResourceURL (javax.portlet.ResourceURL)17 MimeResponse (javax.portlet.MimeResponse)6 UserNode (org.exoplatform.portal.mop.user.UserNode)5 JSONArray (org.json.JSONArray)5 JSONObject (org.json.JSONObject)5 ExternalContext (javax.faces.context.ExternalContext)3 NavigationResource (org.exoplatform.web.url.navigation.NavigationResource)3 NodeURL (org.exoplatform.web.url.navigation.NodeURL)3 IOException (java.io.IOException)2 StringWriter (java.io.StringWriter)2 MalformedURLException (java.net.MalformedURLException)2 PortletResponse (javax.portlet.PortletResponse)2 PortletURL (javax.portlet.PortletURL)2 WebuiRequestContext (org.exoplatform.webui.application.WebuiRequestContext)2 BridgeTest (com.liferay.faces.bridge.tck.annotation.BridgeTest)1 SystemException (com.liferay.portal.kernel.exception.SystemException)1 FileEntry (com.liferay.portal.kernel.repository.model.FileEntry)1 OutputStream (java.io.OutputStream)1 PrintWriter (java.io.PrintWriter)1 Writer (java.io.Writer)1