Author: julien_viet
Date: 2010-09-15 12:16:09 -0400 (Wed, 15 Sep 2010)
New Revision: 4215
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/URLBuilder.java
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceURL.java
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/application/UIComponentURLBuilder.java
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/application/WebuiRequestContext.java
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/url/PortalURL.java
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplication.java
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java
Log:
- rewrote PortletURLBuilder to use PortletURL
- rewrote UIPortlet url generation to use PortalURL instead
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-15
11:16:29 UTC (rev 4214)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/application/RequestContext.java 2010-09-15
16:16:09 UTC (rev 4215)
@@ -53,15 +53,22 @@
private Application app_;
- protected RequestContext parentAppRequestContext_;
+ protected final RequestContext parentAppRequestContext_;
private Map<String, Object> attributes;
public RequestContext(Application app)
{
- app_ = app;
+ this.app_ = app;
+ this.parentAppRequestContext_ = null;
}
+ protected RequestContext(RequestContext parentAppRequestContext, Application app_)
+ {
+ this.parentAppRequestContext_ = parentAppRequestContext;
+ this.app_ = app_;
+ }
+
public Application getApplication()
{
return app_;
@@ -194,11 +201,6 @@
return parentAppRequestContext_;
}
- public void setParentAppRequestContext(RequestContext context)
- {
- parentAppRequestContext_ = context;
- }
-
@SuppressWarnings("unchecked")
public static <T extends RequestContext> T getCurrentInstance()
{
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
11:16:29 UTC (rev 4214)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/application/URLBuilder.java 2010-09-15
16:16:09 UTC (rev 4215)
@@ -28,23 +28,6 @@
abstract public class URLBuilder<T>
{
- protected String baseURL_;
-
- public URLBuilder(String baseURL)
- {
- baseURL_ = baseURL;
- }
-
- public String getBaseURL()
- {
- return baseURL_;
- }
-
- public void setBaseURL(String url)
- {
- baseURL_ = url;
- }
-
public String createURL(String action)
{
return createURL(action, (Parameter[])null);
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-15
11:16:29 UTC (rev 4214)
+++
portal/branches/navcontroller/component/web/controller/src/main/java/org/exoplatform/web/url/ResourceURL.java 2010-09-15
16:16:09 UTC (rev 4215)
@@ -19,6 +19,10 @@
package org.exoplatform.web.url;
+import org.gatein.common.util.ParameterMap;
+
+import java.util.Map;
+
/**
* An URL for a resource.
*
@@ -29,6 +33,9 @@
{
/** . */
+ private static final ParameterMap.AccessMode ACCES_MODE =
ParameterMap.AccessMode.get(false, false);
+
+ /** . */
protected final L locator;
/** . */
@@ -37,6 +44,9 @@
/** . */
protected String confirm;
+ /** . */
+ protected ParameterMap queryParams;
+
/**
* Create a resource URL instance.
*
@@ -55,6 +65,7 @@
this.locator = locator;
this.ajax = ajax;
this.confirm = null;
+ this.queryParams = null;
}
/**
@@ -103,10 +114,12 @@
* Updates the confirm message.
*
* @param confirm the new confirm message
+ * @return this object
*/
- public void setConfirm(String confirm)
+ public final ResourceURL setConfirm(String confirm)
{
this.confirm = confirm;
+ return this;
}
/**
@@ -123,6 +136,7 @@
* Set a new resource on this URL.
*
* @param resource the new resource
+ * @return this object
*/
public final ResourceURL setResource(R resource)
{
@@ -130,6 +144,67 @@
return this;
}
+ public Map<String, String[]> getQueryParameters()
+ {
+ if (queryParams == null)
+ {
+ queryParams = new ParameterMap(ACCES_MODE);
+ }
+ return queryParams;
+ }
+
+ public String getQueryParameterValue(String parameterName)
+ {
+ if (parameterName == null)
+ {
+ throw new NullPointerException("");
+ }
+ else if (queryParams == null)
+ {
+ return null;
+ }
+ else
+ {
+ String[] parameterValues = queryParams.get(parameterName);
+ return parameterValues != null ? parameterValues[0] : null;
+ }
+ }
+
+ public void setQueryParameterValue(String parameterName, String parameterValue)
+ {
+ if (parameterName == null)
+ {
+ throw new NullPointerException("No null parameter name");
+ }
+ if (queryParams == null)
+ {
+ queryParams = new ParameterMap(ACCES_MODE);
+ }
+ queryParams.setValue(parameterName, parameterValue);
+ }
+
+ public String[] getQueryParameterValues(String parameterName)
+ {
+ if (parameterName == null)
+ {
+ throw new NullPointerException("No null parameter name");
+ }
+ return queryParams != null ? queryParams.getValues(parameterName) : null;
+ }
+
+ public void setQueryParameterValues(String parameterName, String[] parameterValues)
+ {
+ if (parameterName == null)
+ {
+ throw new NullPointerException("No null parameter name");
+ }
+ if (queryParams == null)
+ {
+ queryParams = new ParameterMap(ACCES_MODE);
+ }
+ queryParams.setValues(parameterName, parameterValues);
+ }
+
/**
* Generates the URL value.
*
Modified:
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/application/UIComponentURLBuilder.java
===================================================================
---
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/application/UIComponentURLBuilder.java 2010-09-15
11:16:29 UTC (rev 4214)
+++
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/application/UIComponentURLBuilder.java 2010-09-15
16:16:09 UTC (rev 4215)
@@ -37,9 +37,6 @@
public UIComponentURLBuilder(ResourceURL<UIComponent, ComponentLocator> url)
{
- super("foo");
-
- //
this.url = url;
}
Modified:
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/application/WebuiRequestContext.java
===================================================================
---
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/application/WebuiRequestContext.java 2010-09-15
11:16:29 UTC (rev 4214)
+++
portal/branches/navcontroller/webui/framework/src/main/java/org/exoplatform/webui/application/WebuiRequestContext.java 2010-09-15
16:16:09 UTC (rev 4215)
@@ -69,6 +69,11 @@
super(app);
}
+ protected WebuiRequestContext(RequestContext parentAppRequestContext, Application
app_)
+ {
+ super(parentAppRequestContext, app_);
+ }
+
public String getSessionId()
{
return sessionId_;
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
11:16:29 UTC (rev 4214)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/application/PortalURLBuilder.java 2010-09-15
16:16:09 UTC (rev 4215)
@@ -64,7 +64,7 @@
protected void createURL(StringBuilder builder, UIComponent targetComponent, String
action, String targetBeanId,
Parameter[] params)
{
-
builder.append(getBaseURL()).append("?").append(PortalRequestContext.UI_COMPONENT_ID).append('=').append(
+
builder.append("baseurl").append("?").append(PortalRequestContext.UI_COMPONENT_ID).append('=').append(
targetComponent.getId());
if (action != null && action.trim().length() > 0)
{
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-15
11:16:29 UTC (rev 4214)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/url/PortalURL.java 2010-09-15
16:16:09 UTC (rev 4215)
@@ -133,7 +133,6 @@
//
boolean questionMarkDone = false;
Map<String, String> queryParams = renderContext.getQueryParams();
- System.out.println("queryParams = " + queryParams);
if (queryParams.size() > 0)
{
for (Map.Entry<String, String> entry : queryParams.entrySet())
@@ -146,6 +145,19 @@
}
}
+ // Now append generic query parameters
+ for (Map.Entry<String, String[]> entry : getQueryParameters().entrySet())
+ {
+ for (String value : entry.getValue())
+ {
+ buffer.append(questionMarkDone ? "&" : "?");
+ buffer.append(entry.getKey());
+ buffer.append("=");
+ buffer.append(value);
+ questionMarkDone = true;
+ }
+ }
+
//
if (ajax)
{
Modified:
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java
===================================================================
---
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java 2010-09-15
11:16:29 UTC (rev 4214)
+++
portal/branches/navcontroller/webui/portal/src/main/java/org/exoplatform/portal/webui/application/ExoPortletInvocationContext.java 2010-09-15
16:16:09 UTC (rev 4215)
@@ -21,6 +21,10 @@
import org.exoplatform.Constants;
import org.exoplatform.portal.application.PortalRequestContext;
+import org.exoplatform.portal.application.PortalRequestHandler;
+import org.exoplatform.webui.application.WebuiRequestContext;
+import org.exoplatform.webui.core.UIComponent;
+import org.exoplatform.webui.url.ComponentLocator;
import org.gatein.common.net.media.MediaType;
import org.gatein.common.util.MarkupInfo;
import org.gatein.common.util.ParameterValidation;
@@ -46,26 +50,32 @@
class ExoPortletInvocationContext extends AbstractPortletInvocationContext
{
- private HttpServletResponse response;
+ static final String INTERACTION_STATE_PARAM_NAME = "interactionstate";
+ static final String NAVIGATIONAL_STATE_PARAM_NAME = "navigationalstate";
+ static final String RESOURCE_STATE_PARAM_NAME = "resourcestate";
- private HttpServletRequest request;
+ /** . */
+ private final HttpServletResponse response;
- private String portalRequestURI;
+ /** . */
+ private final HttpServletRequest request;
- private String portletId;
+ /** . */
+ private final org.exoplatform.web.url.ResourceURL<UIComponent, ComponentLocator>
url;
- static final String INTERACTION_STATE_PARAM_NAME = "interactionstate";
- static final String NAVIGATIONAL_STATE_PARAM_NAME = "navigationalstate";
- static final String RESOURCE_STATE_PARAM_NAME = "resourcestate";
-
public ExoPortletInvocationContext(PortalRequestContext portalRequestContext,
UIPortlet portlet)
{
super(new MarkupInfo(MediaType.create("text/html"), "UTF-8"));
+ //
+ org.exoplatform.web.url.ResourceURL<UIComponent,ComponentLocator> url =
portalRequestContext.createURL(ComponentLocator.TYPE, portlet);
+ String path = portalRequestContext.getNodePath();
+ url.getResourceLocator().setParameterValue(PortalRequestHandler.REQUEST_PATH,
path);
+
+ //
this.request = portalRequestContext.getRequest();
this.response = portalRequestContext.getResponse();
- this.portalRequestURI = portalRequestContext.getRequestURI();
- this.portletId = portlet.getId();
+ this.url = url;
}
@Override
@@ -92,9 +102,12 @@
public String renderURL(ContainerURL containerURL, URLFormat format)
{
+
+/*
// todo: shouldn't we be using URLFormat to decide on the path to use at the
beginning of the URL?
StringBuilder baseURL = new
StringBuilder(this.portalRequestURI).append("?")
.append(PortalRequestContext.UI_COMPONENT_ID).append("=").append(this.portletId);
+*/
String type;
if (containerURL instanceof RenderURL)
@@ -116,12 +129,12 @@
if (!type.equals(Constants.PORTAL_RENDER))
{
- appendParameter(baseURL, Constants.TYPE_PARAMETER, type);
+ url.setQueryParameterValue(Constants.TYPE_PARAMETER, type);
}
if (format != null && format.getWantSecure() != null)
{
- appendParameter(baseURL, Constants.SECURE_PARAMETER,
format.getWantSecure().toString());
+ url.setQueryParameterValue(Constants.SECURE_PARAMETER,
format.getWantSecure().toString());
}
if (containerURL instanceof ActionURL)
@@ -131,61 +144,61 @@
StateString state = actionURL.getInteractionState();
if (state != null &&
!state.getStringValue().equals(StateString.JBPNS_PREFIX))
{
- appendParameter(baseURL, INTERACTION_STATE_PARAM_NAME,
state.getStringValue());
+ url.setQueryParameterValue(INTERACTION_STATE_PARAM_NAME,
state.getStringValue());
}
state = actionURL.getNavigationalState();
if (state != null &&
!state.getStringValue().equals(StateString.JBPNS_PREFIX))
{
- appendParameter(baseURL, NAVIGATIONAL_STATE_PARAM_NAME,
state.getStringValue());
+ url.setQueryParameterValue(NAVIGATIONAL_STATE_PARAM_NAME,
state.getStringValue());
}
WindowState windowState = actionURL.getWindowState();
if (windowState != null)
{
- appendParameter(baseURL, Constants.WINDOW_STATE_PARAMETER,
windowState.toString());
+ url.setQueryParameterValue(Constants.WINDOW_STATE_PARAMETER,
windowState.toString());
}
Mode mode = actionURL.getMode();
if (mode != null)
{
- appendParameter(baseURL, Constants.PORTLET_MODE_PARAMETER, mode.toString());
+ url.setQueryParameterValue(Constants.PORTLET_MODE_PARAMETER,
mode.toString());
}
}
else if (containerURL instanceof ResourceURL)
{
ResourceURL resourceURL = (ResourceURL)containerURL;
- appendParameter(baseURL, Constants.RESOURCE_ID_PARAMETER,
resourceURL.getResourceId());
+ url.setQueryParameterValue(Constants.RESOURCE_ID_PARAMETER,
resourceURL.getResourceId());
CacheLevel cachability = resourceURL.getCacheability();
if (cachability != null)
{
- appendParameter(baseURL, Constants.CACHELEVEL_PARAMETER,
cachability.name());
+ url.setQueryParameterValue(Constants.CACHELEVEL_PARAMETER,
cachability.name());
}
StateString resourceState = resourceURL.getResourceState();
if (resourceState != null &&
!resourceState.getStringValue().equals(StateString.JBPNS_PREFIX))
{
- appendParameter(baseURL, RESOURCE_STATE_PARAM_NAME,
resourceState.getStringValue());
+ url.setQueryParameterValue(RESOURCE_STATE_PARAM_NAME,
resourceState.getStringValue());
}
resourceState = resourceURL.getNavigationalState();
if (resourceState != null &&
!resourceState.getStringValue().equals(StateString.JBPNS_PREFIX))
{
- appendParameter(baseURL, NAVIGATIONAL_STATE_PARAM_NAME,
resourceState.getStringValue());
+ url.setQueryParameterValue(NAVIGATIONAL_STATE_PARAM_NAME,
resourceState.getStringValue());
}
WindowState windowState = resourceURL.getWindowState();
if (windowState != null)
{
- appendParameter(baseURL, Constants.WINDOW_STATE_PARAMETER,
windowState.toString());
+ url.setQueryParameterValue(Constants.WINDOW_STATE_PARAMETER,
windowState.toString());
}
Mode mode = resourceURL.getMode();
if (mode != null)
{
- appendParameter(baseURL, Constants.PORTLET_MODE_PARAMETER, mode.toString());
+ url.setQueryParameterValue(Constants.PORTLET_MODE_PARAMETER,
mode.toString());
}
}
else
@@ -195,13 +208,13 @@
WindowState windowState = renderURL.getWindowState();
if (windowState != null)//&& !windowState.equals(WindowState.NORMAL))
{
- appendParameter(baseURL, Constants.WINDOW_STATE_PARAMETER,
windowState.toString());
+ url.setQueryParameterValue(Constants.WINDOW_STATE_PARAMETER,
windowState.toString());
}
Mode mode = renderURL.getMode();
if (mode != null)
{
- appendParameter(baseURL, Constants.PORTLET_MODE_PARAMETER, mode.toString());
+ url.setQueryParameterValue(Constants.PORTLET_MODE_PARAMETER,
mode.toString());
}
Map<String, String[]> publicNSChanges =
renderURL.getPublicNavigationalStateChanges();
@@ -214,12 +227,12 @@
{
for (String value : values)
{
- appendParameter(baseURL, key, value);
+ url.setQueryParameterValue(key, value);
}
}
else
{
- appendParameter(baseURL, "removePP", key);
+ url.setQueryParameterValue("removePP", key);
}
}
}
@@ -227,18 +240,14 @@
StateString state = renderURL.getNavigationalState();
if (state != null &&
!state.getStringValue().equals(StateString.JBPNS_PREFIX))
{
- appendParameter(baseURL, NAVIGATIONAL_STATE_PARAM_NAME,
state.getStringValue());
+ url.setQueryParameterValue(NAVIGATIONAL_STATE_PARAM_NAME,
state.getStringValue());
}
}
- return baseURL.toString();
- }
+ //
+ String s = url.toString();
- private void appendParameter(StringBuilder builder, String name, String value)
- {
- if (value != null)
- {
-
builder.append("&").append(name).append("=").append(value);
- }
+ //
+ return s;
}
}
Modified:
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplication.java
===================================================================
---
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplication.java 2010-09-15
11:16:29 UTC (rev 4214)
+++
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletApplication.java 2010-09-15
16:16:09 UTC (rev 4215)
@@ -307,10 +307,9 @@
}
else
{
- context = new PortletRequestContext(this, w, req, res);
+ context = new PortletRequestContext(parentAppRequestContext, this, w, req,
res);
parentAppRequestContext.setAttribute(attributeName, context);
}
- context.setParentAppRequestContext(parentAppRequestContext);
return context;
}
Modified:
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java
===================================================================
---
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java 2010-09-15
11:16:29 UTC (rev 4214)
+++
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletRequestContext.java 2010-09-15
16:16:09 UTC (rev 4215)
@@ -21,6 +21,7 @@
import org.exoplatform.commons.utils.WriterPrinter;
import org.exoplatform.services.resources.Orientation;
+import org.exoplatform.web.application.RequestContext;
import org.exoplatform.web.application.URLBuilder;
import org.exoplatform.web.url.LocatorProvider;
import org.exoplatform.web.url.ResourceLocator;
@@ -34,14 +35,17 @@
import java.io.Writer;
import javax.portlet.ActionResponse;
+import javax.portlet.MimeResponse;
import javax.portlet.PortletMode;
import javax.portlet.PortletModeException;
import javax.portlet.PortletRequest;
import javax.portlet.PortletResponse;
-import javax.portlet.RenderResponse;
import javax.portlet.StateAwareResponse;
/**
+ * todo (julien) : there is an issue here (small) as the PRC seems to be stored in http
session
+ * and keep a pointer on request and response object.
+ *
* The request context of a portlet
*
*/
@@ -66,15 +70,14 @@
private boolean hasProcessAction_ = false;
- private final PortletURLBuilder urlBuilder;
+ /** . */
+ private PortletURLBuilder urlBuilder;
- public PortletRequestContext(WebuiApplication app, Writer writer, PortletRequest req,
PortletResponse res)
+ public PortletRequestContext(RequestContext parentAppRequestContext, WebuiApplication
app, Writer writer, PortletRequest req, PortletResponse res)
{
- super(app);
+ super(parentAppRequestContext, app);
init(writer, req, res);
setSessionId(req.getPortletSession(true).getId());
-
- urlBuilder = new PortletURLBuilder();
}
@Override
@@ -89,6 +92,16 @@
response_ = res;
writer_ = new WriterPrinter(writer);
windowId_ = req.getWindowID();
+
+ //
+ if (res instanceof MimeResponse)
+ {
+ this.urlBuilder = new PortletURLBuilder(((MimeResponse)res).createActionURL());
+ }
+ else
+ {
+ this.urlBuilder = null;
+ }
}
public void setUIApplication(UIApplication uiApplication) throws Exception
@@ -211,8 +224,10 @@
public URLBuilder<UIComponent> getURLBuilder()
{
- RenderResponse renderRes = (RenderResponse)response_;
- urlBuilder.setBaseURL(renderRes.createActionURL().toString());
+ if (urlBuilder == null)
+ {
+ throw new IllegalStateException("Cannot create portlet URL during
action/event phase");
+ }
return urlBuilder;
}
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
11:16:29 UTC (rev 4214)
+++
portal/branches/navcontroller/webui/portlet/src/main/java/org/exoplatform/webui/application/portlet/PortletURLBuilder.java 2010-09-15
16:16:09 UTC (rev 4215)
@@ -24,6 +24,8 @@
import org.exoplatform.webui.application.WebuiRequestContext;
import org.exoplatform.webui.core.UIComponent;
+import javax.portlet.PortletURL;
+
/**
* julien todo : use PortletURL parameter instead of appending them to the url returned
by the PortletURL
*
@@ -32,17 +34,13 @@
*/
public class PortletURLBuilder extends URLBuilder<UIComponent>
{
- private static final String AMP = "&";
- private static final char EQUALS = '=';
- public PortletURLBuilder()
- {
- super(null);
- }
+ /** . */
+ private final PortletURL url;
- public PortletURLBuilder(String baseURL)
+ public PortletURLBuilder(PortletURL url)
{
- super(baseURL);
+ this.url = url;
}
public String createURL(String action, Parameter[] params)
@@ -58,27 +56,34 @@
protected void createURL(StringBuilder builder, UIComponent targetComponent, String
action, String targetBeanId,
Parameter[] params)
{
- String baseUrl = getBaseURL().replaceAll("&", AMP);
-
builder.append(baseUrl).append(AMP).append(UIComponent.UICOMPONENT).append(EQUALS).append(
- targetComponent.getId());
+ // Clear URL
+ url.getParameterMap().clear();
+ //
+ url.setParameter(UIComponent.UICOMPONENT, targetComponent.getId());
+
+ //
if (action != null && action.trim().length() > 0)
{
-
builder.append(AMP).append(WebuiRequestContext.ACTION).append(EQUALS).append(action);
+ url.setParameter(WebuiRequestContext.ACTION, action);
}
+ //
if (targetBeanId != null && targetBeanId.trim().length() > 0)
{
-
builder.append(AMP).append(UIComponent.OBJECTID).append(EQUALS).append(targetBeanId);
+ url.setParameter(UIComponent.OBJECTID, targetBeanId);
}
- if (params == null || params.length < 1)
- return;
- for (Parameter param : params)
+ //
+ if (params != null && params.length > 0)
{
-
builder.append(AMP).append(param.getName()).append(EQUALS).append(param.getValue());
+ for (Parameter param : params)
+ {
+ url.setParameter(param.getName(), param.getValue());
+ }
}
+ //
+ builder.append(url.toString());
}
-
}