Author: julien_viet
Date: 2010-09-13 06:29:08 -0400 (Mon, 13 Sep 2010)
New Revision: 4169
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/ControllerContext.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/SimpleRenderContext.java
portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/web.xml
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java
Log:
update to use new RenderContext
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/ControllerContext.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/ControllerContext.java 2010-09-13
09:33:19 UTC (rev 4168)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/ControllerContext.java 2010-09-13
10:29:08 UTC (rev 4169)
@@ -20,6 +20,8 @@
package org.exoplatform.web;
import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.controller.router.RenderContext;
+import org.exoplatform.web.controller.router.SimpleRenderContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -44,6 +46,9 @@
/** . */
private final Map<QualifiedName, String> parameters;
+ /** . */
+ private SimpleRenderContext renderContext;
+
ControllerContext(
WebAppController controller,
HttpServletRequest request,
@@ -54,6 +59,7 @@
this.request = request;
this.response = response;
this.parameters = parameters;
+ this.renderContext = null;
}
public WebAppController getController()
@@ -76,8 +82,32 @@
return parameters.get(parameter);
}
+ public void renderURL(Map<QualifiedName, String> parameters, RenderContext
renderContext)
+ {
+ renderContext.appendPath(request.getContextPath());
+
+ //
+ controller.router.render(parameters, renderContext);
+ }
+
public String renderURL(Map<QualifiedName, String> parameters)
{
- return request.getContextPath() + controller.router.render(parameters);
+ if (renderContext == null)
+ {
+ renderContext = new SimpleRenderContext();
+ }
+ else
+ {
+ renderContext.reset();
+ }
+
+ //
+ renderContext.appendPath(request.getContextPath());
+
+ //
+ controller.router.render(parameters, renderContext);
+
+ //
+ return renderContext.getPath();
}
}
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/SimpleRenderContext.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/SimpleRenderContext.java 2010-09-13
09:33:19 UTC (rev 4168)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/controller/router/SimpleRenderContext.java 2010-09-13
10:29:08 UTC (rev 4169)
@@ -36,6 +36,15 @@
/** . */
private Map<String, String> queryParams = Collections.emptyMap();
+ public SimpleRenderContext()
+ {
+ }
+
+ public SimpleRenderContext(StringBuilder sb)
+ {
+ this.sb = sb;
+ }
+
public String getPath()
{
return sb != null ? sb.toString() : null;
@@ -46,6 +55,18 @@
return queryParams;
}
+ public void reset()
+ {
+ if (sb != null)
+ {
+ sb.setLength(0);
+ }
+ if (queryParams.size() > 0)
+ {
+ queryParams.clear();
+ }
+ }
+
public void appendPath(char c)
{
if (sb == null)
Modified: portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/web.xml
===================================================================
--- portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/web.xml 2010-09-13
09:33:19 UTC (rev 4168)
+++ portal/branches/navcontroller/web/portal/src/main/webapp/WEB-INF/web.xml 2010-09-13
10:29:08 UTC (rev 4169)
@@ -277,7 +277,25 @@
<url-pattern>/</url-pattern>
</servlet-mapping>
+ <!-- Explicit mappings (due to portal servlet on '/') for UIHomePagePortlet,
need to find out how to improve that -->
<servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>*.jpg</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>*.png</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>*.gif</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>default</servlet-name>
+ <url-pattern>*.css</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
<servlet-name>GateInServlet</servlet-name>
<url-pattern>/gateinservlet</url-pattern>
</servlet-mapping>
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-13
09:33:19 UTC (rev 4168)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java 2010-09-13
10:29:08 UTC (rev 4169)
@@ -24,6 +24,8 @@
import org.exoplatform.web.ControllerContext;
import org.exoplatform.web.WebAppController;
import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.controller.router.RenderContext;
+import org.exoplatform.web.controller.router.SimpleRenderContext;
import org.exoplatform.web.url.ResourceLocator;
import org.exoplatform.web.url.ResourceURL;
@@ -41,6 +43,12 @@
/** . */
private final PortalRequestContext requestContext;
+ /** . */
+ private StringBuilder buffer;
+
+ /** . */
+ private SimpleRenderContext renderContext;
+
public PortalURL(PortalRequestContext requestContext, L locator, Boolean ajax)
{
super(locator, ajax);
@@ -58,7 +66,15 @@
public String toString()
{
//
- StringBuilder url = new StringBuilder();
+ if (renderContext == null)
+ {
+ buffer = new StringBuilder();
+ renderContext = new SimpleRenderContext(buffer);
+ }
+ else
+ {
+ renderContext.reset();
+ }
//
if (locator.getResource() == null)
@@ -69,7 +85,7 @@
//
if (ajax)
{
- url.append("javascript:ajaxGet('");
+ buffer.append("javascript:ajaxGet('");
}
//
@@ -92,20 +108,16 @@
parameters.put(WebAppController.HANDLER_PARAM, "portal");
//
- ControllerContext controllerContext = requestContext.getControllerContext();
- String s = controllerContext.renderURL(parameters);
+ requestContext.getControllerContext().renderURL(parameters, renderContext);
//
- url.append(s);
-
- //
if (ajax)
{
- url.append("?ajaxRequest=true");
- url.append("')");
+ buffer.append("?ajaxRequest=true");
+ buffer.append("')");
}
//
- return url.toString();
+ return buffer.toString();
}
}
Show replies by date