Author: julien_viet
Date: 2010-09-05 15:22:29 -0400 (Sun, 05 Sep 2010)
New Revision: 4046
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceURL.java
portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UISitemapTree.gtmpl
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java
Log:
start to use url api for creating navigation node urls in the SiteMapPortlet
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java 2010-09-05
11:49:55 UTC (rev 4045)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java 2010-09-05
19:22:29 UTC (rev 4046)
@@ -83,6 +83,17 @@
public final <R, L extends ResourceLocator<R>> ResourceURL<R, L>
createURL(ResourceType<R, L> resourceType, R resource)
{
+ ResourceURL<R, L> url = createURL(resourceType);
+
+ // Set the resource on the URL
+ url.setResource(resource);
+
+ //
+ return url;
+ }
+
+ public final <R, L extends ResourceLocator<R>> ResourceURL<R, L>
createURL(ResourceType<R, L> resourceType)
+ {
// Get the provider
LocatorProvider provider = getLocatorProvider();
@@ -96,13 +107,7 @@
}
// Create an URL from the locator
- ResourceURL<R, L> url = newURL(resourceType, locator);
-
- // Set the resource on the URL
- url.setResource(resource);
-
- // Returns the URL object
- return url;
+ return newURL(resourceType, locator);
}
/**
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceURL.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceURL.java 2010-09-05
11:49:55 UTC (rev 4045)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceURL.java 2010-09-05
19:22:29 UTC (rev 4046)
@@ -73,9 +73,10 @@
*
* @param resource the new resource
*/
- public final void setResource(R resource)
+ public final ResourceURL setResource(R resource)
{
locator.setResource(resource);
+ return this;
}
/**
Modified:
portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UISitemapTree.gtmpl
===================================================================
---
portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UISitemapTree.gtmpl 2010-09-05
11:49:55 UTC (rev 4045)
+++
portal/branches/navcontroller/web/portal/src/main/webapp/groovy/webui/core/UISitemapTree.gtmpl 2010-09-05
19:22:29 UTC (rev 4046)
@@ -4,21 +4,23 @@
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.portal.webui.util.Util;
import org.exoplatform.portal.webui.navigation.TreeNode;
-%>
+ import org.exoplatform.web.url.ResourceURL;
+%>
<%
def navigations = uicomponent.getNavigations();
PortalRequestContext pcontext = Util.getPortalRequestContext();
- def String portalURI = pcontext.getPortalURI();
-
+
UIPortletApplication siteMapPortlet = uicomponent.getParent();
def useAJAX = siteMapPortlet.isUseAjax();
def actionExpandAll = uicomponent.event("ExpandAllNode");
def actionCollapseAll = uicomponent.event("CollapseAllNode");
+
+ ResourceURL nodeURL =
pcontext.createURL(org.exoplatform.portal.url.navigation.NavigationLocator.TYPE);
- public void renderNodes(TreeNode rootTree, String portalUri, boolean useAjax) {
+ public void renderNodes(TreeNode rootTree, ResourceURL nodeURL, boolean useAjax) {
List childrenNodes=rootTree.getChildren();
int childrenSize = childrenNodes.size() ;
int size = 0;
@@ -36,7 +38,7 @@
if(useAjax){
actionLink = uicomponent.event("SelectNode", nav.getId() + "::" +
node.getUri());
}else{
- actionLink = portalUri + node.getUri();
+ actionLink = nodeURL.setResource(node).toString();
}
lastNode = '';
@@ -59,7 +61,7 @@
<div class="ChildrenContainer" style="display: block">
""";
- renderNodes(treeNode, portalUri, useAjax);
+ renderNodes(treeNode, nodeURL, useAjax);
} else {
println """
@@ -110,7 +112,7 @@
<div class="SitemapContent">
<div class="UISiteTree">
<% TreeNode treeNodeRoot = uicomponent.getTreeNodes() ;%>
- <% renderNodes(treeNodeRoot,portalURI,useAJAX); %>
+ <% renderNodes(treeNodeRoot,nodeURL,useAJAX); %>
</div>
</div>
</div>
Modified:
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java
===================================================================
---
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java 2010-09-05
11:49:55 UTC (rev 4045)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java 2010-09-05
19:22:29 UTC (rev 4046)
@@ -23,6 +23,8 @@
import org.exoplatform.web.url.ResourceLocator;
import org.exoplatform.web.url.ResourceURL;
+import java.io.IOException;
+
/**
* @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
* @version $Revision$
@@ -61,6 +63,18 @@
sb.append(requestContext.getPortalURI());
//
+ try
+ {
+ locator.append(sb);
+ }
+ catch (IOException e)
+ {
+ AssertionError ae = new AssertionError();
+ ae.initCause(e);
+ throw ae;
+ }
+
+ //
return sb.toString();
}
}