Author: julien_viet
Date: 2010-09-13 09:25:39 -0400 (Mon, 13 Sep 2010)
New Revision: 4173
Added:
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/component/
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentLocator.java
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceLocator.java
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/navigation/NavigationLocator.java
Log:
rework the ResourceLocator interface
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceLocator.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceLocator.java 2010-09-13
13:15:25 UTC (rev 4172)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceLocator.java 2010-09-13
13:25:39 UTC (rev 4173)
@@ -19,8 +19,10 @@
package org.exoplatform.web.url;
-import java.io.IOException;
+import org.exoplatform.web.controller.QualifiedName;
+import java.util.Set;
+
/**
* <p>A locator for a resource.</p>
*
@@ -48,11 +50,18 @@
void setResource(R resource);
/**
- * Append the resource locator path.
+ * Returns the set of parameter names provided this locator.
*
- * @param appendable the appendable
- * @throws IOException any IOException thrown by the appendable
+ * @return the parameter names
*/
- void append(Appendable appendable) throws IOException;
+ Set<QualifiedName> getParameterNames();
+ /**
+ * Returns a specified parameter value or null when it is not available
+ *
+ * @param parameterName the parameter name
+ * @return the parameter value
+ */
+ String getParameterValue(QualifiedName parameterName);
+
}
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
13:15:25 UTC (rev 4172)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java 2010-09-13
13:25:39 UTC (rev 4173)
@@ -88,26 +88,19 @@
buffer.append("javascript:ajaxGet('");
}
- //
- StringBuilder builder = new StringBuilder();
- try
- {
- locator.append(builder);
- }
- catch (IOException e)
- {
- AssertionError ae = new AssertionError();
- ae.initCause(e);
- throw ae;
- }
-
// julien : find out how to change the hardcoded "classic"
Map<QualifiedName, String> parameters = new HashMap<QualifiedName,
String>();
- parameters.put(PortalRequestHandler.REQUEST_PATH, builder.toString());
parameters.put(PortalRequestHandler.REQUEST_SITE_NAME, "classic");
parameters.put(WebAppController.HANDLER_PARAM, "portal");
//
+ for (QualifiedName parameterName : locator.getParameterNames())
+ {
+ String parameterValue = locator.getParameterValue(parameterName);
+ parameters.put(parameterName, parameterValue);
+ }
+
+ //
requestContext.getControllerContext().renderURL(parameters, renderContext);
//
Added:
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentLocator.java
===================================================================
---
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentLocator.java
(rev 0)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/component/ComponentLocator.java 2010-09-13
13:25:39 UTC (rev 4173)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2010 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.exoplatform.portal.url.component;
+
+import org.exoplatform.web.controller.QualifiedName;
+import org.exoplatform.web.url.ResourceLocator;
+import org.exoplatform.webui.core.UIComponent;
+
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:julien.viet@exoplatform.com">Julien
Viet</a>
+ * @version $Revision$
+ */
+public class ComponentLocator implements ResourceLocator<UIComponent>
+{
+
+ /** . */
+ private UIComponent resource;
+
+ public UIComponent getResource()
+ {
+ return resource;
+ }
+
+ public void setResource(UIComponent resource)
+ {
+ this.resource = resource;
+ }
+
+ public Set<QualifiedName> getParameterNames()
+ {
+ return Collections.emptySet();
+ }
+
+ public String getParameterValue(QualifiedName parameterName)
+ {
+ return null;
+ }
+}
Modified:
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationLocator.java
===================================================================
---
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationLocator.java 2010-09-13
13:15:25 UTC (rev 4172)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/navigation/NavigationLocator.java 2010-09-13
13:25:39 UTC (rev 4173)
@@ -20,10 +20,12 @@
package org.exoplatform.portal.url.navigation;
import org.exoplatform.portal.config.model.PageNode;
+import org.exoplatform.web.controller.QualifiedName;
import org.exoplatform.web.url.ResourceLocator;
import org.exoplatform.web.url.ResourceType;
-import java.io.IOException;
+import java.util.Collections;
+import java.util.Set;
/**
* A resource locator for navigation nodes.
@@ -35,9 +37,15 @@
{
/** . */
+ public static final QualifiedName PATH = new QualifiedName("gtn",
"path");
+
+ /** . */
public static final ResourceType<PageNode, NavigationLocator> TYPE = new
ResourceType<PageNode, NavigationLocator>(){};
/** . */
+ private static final Set<QualifiedName> PARAMETER_NAMES =
Collections.singleton(PATH);
+
+ /** . */
private PageNode resource;
public PageNode getResource()
@@ -50,8 +58,17 @@
this.resource = resource;
}
- public void append(Appendable appendable) throws IOException
+ public Set<QualifiedName> getParameterNames()
{
- appendable.append('/').append(resource.getUri());
+ return PARAMETER_NAMES;
}
+
+ public String getParameterValue(QualifiedName parameterName)
+ {
+ if (PATH.equals(parameterName))
+ {
+ return "/" + resource.getUri();
+ }
+ return null;
+ }
}