Author: julien_viet
Date: 2010-09-15 15:25:48 -0400 (Wed, 15 Sep 2010)
New Revision: 4216
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/application/URLBuilder.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalURLBuilder.java
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java
Log:
URLBuilder cleanup
Modified:
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/application/URLBuilder.java
===================================================================
---
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/application/URLBuilder.java 2010-09-15
16:16:09 UTC (rev 4215)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/application/URLBuilder.java 2010-09-15
19:25:48 UTC (rev 4216)
@@ -19,8 +19,6 @@
package org.exoplatform.web.application;
-import java.net.URLEncoder;
-
/**
* Created by The eXo Platform SAS
* Mar 29, 2007
@@ -28,85 +26,42 @@
abstract public class URLBuilder<T>
{
- public String createURL(String action)
+ public final String createURL(String action)
{
- return createURL(action, (Parameter[])null);
+ throw new UnsupportedOperationException("don't use me");
}
- abstract public String createURL(String action, Parameter[] params);
-
- public String createURL(String action, String objectId)
+ public final String createURL(String action, Parameter[] params)
{
- return createURL(action, objectId, (Parameter[])null);
+ throw new UnsupportedOperationException("don't use me");
}
- abstract public String createURL(String action, String objectId, Parameter[] params);
-
- public String createURL(T targetComponent, String action, String targetBeanId)
+ public final String createURL(String action, String objectId)
{
- return createURL(targetComponent, action, null, targetBeanId, (Parameter[])null);
+ throw new UnsupportedOperationException("don't use me");
}
- public String createAjaxURL(T targetComponent, String action, String targetBeanId)
+ public final String createURL(String action, String objectId, Parameter[] params)
{
- return createAjaxURL(targetComponent, action, null, targetBeanId,
(Parameter[])null);
+ throw new UnsupportedOperationException("don't use me");
}
- public String createAjaxURL(T targetComponent, String action, String confirm, String
targetBeanId)
+ public final String createURL(T targetComponent, String action, String targetBeanId)
{
- return createAjaxURL(targetComponent, action, confirm, targetBeanId,
(Parameter[])null);
+ return createURL(targetComponent, action, null, targetBeanId, (Parameter[])null);
}
- public String createAjaxURL(T targetComponent, String action, String confirm, String
targetBeanId, Parameter[] params)
+ public final String createAjaxURL(T targetComponent, String action, String
targetBeanId)
{
- StringBuilder builder = new StringBuilder("javascript:");
- if (confirm != null && confirm.length() > 0)
- {
-
builder.append("if(confirm('").append(confirm.replaceAll("'",
"\\\\'")).append("'))");
- }
- builder.append("ajaxGet('");
- if (targetBeanId != null)
- {
- try
- {
- targetBeanId = URLEncoder.encode(targetBeanId, "utf-8");
- }
- catch (Exception e)
- {
- System.err.println(e.toString());
- }
- }
- createURL(builder, targetComponent, action, targetBeanId, params);
- builder.append("&ajaxRequest=true')");
- return builder.toString();
+ return createAjaxURL(targetComponent, action, null, targetBeanId,
(Parameter[])null);
}
- public String createURL(T targetComponent, String action, String confirm, String
targetBeanId, Parameter[] params)
+ public final String createAjaxURL(T targetComponent, String action, String confirm,
String targetBeanId)
{
- StringBuilder builder = new StringBuilder();
- boolean hasConfirm = confirm != null && confirm.length() > 0;
- if (hasConfirm)
- {
-
builder.append("javascript:if(confirm('").append(confirm.replaceAll("'",
"\\\\'")).append("'))");
- builder.append("window.location=\'");
- }
- if (targetBeanId != null)
- {
- try
- {
- targetBeanId = URLEncoder.encode(targetBeanId, "utf-8");
- }
- catch (Exception e)
- {
- System.err.println(e.toString());
- }
- }
- createURL(builder, targetComponent, action, targetBeanId, params);
- if (hasConfirm)
- builder.append("\';");
- return builder.toString();
+ return createAjaxURL(targetComponent, action, confirm, targetBeanId,
(Parameter[])null);
}
- abstract protected void createURL(StringBuilder builder, T targetComponent, String
action, String targetBeanId,
- Parameter[] params);
+ public abstract String createAjaxURL(T targetComponent, String action, String confirm,
String targetBeanId, Parameter[] params);
+
+ public abstract String createURL(T targetComponent, String action, String confirm,
String targetBeanId, Parameter[] params);
}
Modified:
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalURLBuilder.java
===================================================================
---
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalURLBuilder.java 2010-09-15
16:16:09 UTC (rev 4215)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalURLBuilder.java 2010-09-15
19:25:48 UTC (rev 4216)
@@ -49,18 +49,6 @@
return url;
}
- @SuppressWarnings("unused")
- public String createURL(String action, Parameter[] params)
- {
- return null;
- }
-
- @SuppressWarnings("unused")
- public String createURL(String action, String objectId, Parameter[] params)
- {
- return null;
- }
-
protected void createURL(StringBuilder builder, UIComponent targetComponent, String
action, String targetBeanId,
Parameter[] params)
{
Modified:
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java
===================================================================
---
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java 2010-09-15
16:16:09 UTC (rev 4215)
+++
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java 2010-09-15
19:25:48 UTC (rev 4216)
@@ -25,6 +25,7 @@
import org.exoplatform.webui.core.UIComponent;
import javax.portlet.PortletURL;
+import java.net.URLEncoder;
/**
* julien todo : use PortletURL parameter instead of appending them to the url returned
by the PortletURL
@@ -43,17 +44,57 @@
this.url = url;
}
- public String createURL(String action, Parameter[] params)
+ public String createAjaxURL(UIComponent targetComponent, String action, String
confirm, String targetBeanId, Parameter[] params)
{
- return null;
+ StringBuilder builder = new StringBuilder("javascript:");
+ if (confirm != null && confirm.length() > 0)
+ {
+
builder.append("if(confirm('").append(confirm.replaceAll("'",
"\\\\'")).append("'))");
+ }
+ builder.append("ajaxGet('");
+ if (targetBeanId != null)
+ {
+ try
+ {
+ targetBeanId = URLEncoder.encode(targetBeanId, "utf-8");
+ }
+ catch (Exception e)
+ {
+ System.err.println(e.toString());
+ }
+ }
+ createURL(builder, targetComponent, action, targetBeanId, params);
+ builder.append("&ajaxRequest=true')");
+ return builder.toString();
}
- public String createURL(String action, String objectId, Parameter[] params)
+ public String createURL(UIComponent targetComponent, String action, String confirm,
String targetBeanId, Parameter[] params)
{
- return null;
+ StringBuilder builder = new StringBuilder();
+ boolean hasConfirm = confirm != null && confirm.length() > 0;
+ if (hasConfirm)
+ {
+
builder.append("javascript:if(confirm('").append(confirm.replaceAll("'",
"\\\\'")).append("'))");
+ builder.append("window.location=\'");
+ }
+ if (targetBeanId != null)
+ {
+ try
+ {
+ targetBeanId = URLEncoder.encode(targetBeanId, "utf-8");
+ }
+ catch (Exception e)
+ {
+ System.err.println(e.toString());
+ }
+ }
+ createURL(builder, targetComponent, action, targetBeanId, params);
+ if (hasConfirm)
+ builder.append("\';");
+ return builder.toString();
}
- protected void createURL(StringBuilder builder, UIComponent targetComponent, String
action, String targetBeanId,
+ private void createURL(StringBuilder builder, UIComponent targetComponent, String
action, String targetBeanId,
Parameter[] params)
{
// Clear URL