Author: sohil.shah(a)jboss.com
Date: 2008-01-06 01:33:29 -0500 (Sun, 06 Jan 2008)
New Revision: 9439
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AsyncActivateAction.java
Modified:
branches/presentation/
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AjaxUpdateWindowStateAction.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/service/PortalRPC.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/service/PortalRPCAsync.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/widget/PortletWindow.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java
Log:
Ajax User Agent - Partial Refresh for arbitrary UI interactions like clicking links,
submitting forms etc
Property changes on: branches/presentation
___________________________________________________________________
Name: svn:ignore
- thirdparty
.classpath
.project
.settings
core-samples
+ thirdparty
.classpath
.project
.settings
core-samples
cms
core-admin
core-cms
search
workflow
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AjaxUpdateWindowStateAction.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AjaxUpdateWindowStateAction.java 2008-01-04
10:26:54 UTC (rev 9438)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AjaxUpdateWindowStateAction.java 2008-01-06
06:33:29 UTC (rev 9439)
@@ -83,6 +83,6 @@
};
Map queryParams = new HashMap();
queryParams.put("windowstate", this.windowState);
- portalRPC.asyncGet(this.getTargetId(), queryParams, callback);
+ portalRPC.asyncActivate(this.getTargetId(), queryParams, callback);
}
}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AsyncActivateAction.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AsyncActivateAction.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/AsyncActivateAction.java 2008-01-06
06:33:29 UTC (rev 9439)
@@ -0,0 +1,86 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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.jboss.portal.presentation.ajax.client.protocol;
+
+import org.jboss.portal.presentation.ajax.client.Session;
+import org.jboss.portal.presentation.ajax.client.model.AjaxUIObject;
+import org.jboss.portal.presentation.ajax.client.service.PortalRPC;
+import org.jboss.portal.presentation.ajax.client.service.PortalRPCAsync;
+
+import java.util.Map;
+import java.util.HashMap;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.rpc.ServiceDefTarget;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class AsyncActivateAction extends ClientAction
+{
+ /**
+ *
+ */
+ private String url = null;
+
+ /**
+ *
+ * @param targetId
+ */
+ public AsyncActivateAction(String url)
+ {
+ this.url = url;
+ }
+
+ /**
+ *
+ */
+ public void execute(final Caller caller)
+ {
+ PortalRPCAsync portalRPC = (PortalRPCAsync)GWT.create(PortalRPC.class);
+
((ServiceDefTarget)portalRPC).setServiceEntryPoint(GWT.getModuleBaseURL()+"/portalrpc");
+ AsyncCallback callback = new AsyncCallback()
+ {
+ public void onSuccess(Object result)
+ {
+ if(result instanceof AjaxShowUIObjectResponse)
+ {
+ AjaxUIObject uiObject = ((AjaxShowUIObjectResponse)result).getUiObject();
+ Session.getInstance().getUiContext().addObject(uiObject);
+ Session.getInstance().setAttribute(Session.display, uiObject.getId());
+ caller.callback(uiObject);
+ }
+ }
+
+ public void onFailure(Throwable caught)
+ {
+ /**
+ * TODO: Handle exception properly
+ */
+ }
+ };
+ portalRPC.asyncActivate(this.url, callback);
+ }
+}
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/service/PortalRPC.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/service/PortalRPC.java 2008-01-04
10:26:54 UTC (rev 9438)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/service/PortalRPC.java 2008-01-06
06:33:29 UTC (rev 9439)
@@ -43,11 +43,19 @@
public ClientResponse loadObject(String objectId);
/**
- * Asynchronously changes the window state of the specified window on the server
+ * Asynchronously send a UI activation to the Portal Server
*
- * @param url
+ * @param uiObjectId
* @gwt.typeArgs queryParams <java.lang.String, java.lang.String>
* @return
*/
- public ClientResponse asyncGet(String url, Map queryParams);
+ public ClientResponse asyncActivate(String uiObjectId, Map queryParams);
+
+ /**
+ * Asynchronously send a UI activation to the Portal Server
+ *
+ * @param url
+ * @return
+ */
+ public ClientResponse asyncActivate(String url);
}
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/service/PortalRPCAsync.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/service/PortalRPCAsync.java 2008-01-04
10:26:54 UTC (rev 9438)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/service/PortalRPCAsync.java 2008-01-06
06:33:29 UTC (rev 9439)
@@ -40,11 +40,19 @@
public void loadObject(String objectId, AsyncCallback callback);
/**
- * Asynchronously changes the window state of the specified window on the server
+ * Asynchronously send a UI activation to the Portal Server
*
- * @param url
+ * @param uiObjectId
* @gwt.typeArgs queryParams <java.lang.String, java.lang.String>
* @param callback
*/
- public void asyncGet(String url, Map queryParams, AsyncCallback callback);
+ public void asyncActivate(String uiObjectId, Map queryParams, AsyncCallback
callback);
+
+ /**
+ * Asynchronously send a UI activation to the Portal Server
+ *
+ * @param url
+ * @param callback
+ */
+ public void asyncActivate(String url, AsyncCallback callback);
}
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/widget/PortletWindow.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/widget/PortletWindow.java 2008-01-04
10:26:54 UTC (rev 9438)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/widget/PortletWindow.java 2008-01-06
06:33:29 UTC (rev 9439)
@@ -22,6 +22,7 @@
******************************************************************************/
package org.jboss.portal.presentation.ajax.client.widget;
+import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.DOM;
@@ -44,7 +45,6 @@
import net.mygwt.ui.client.widget.IconButton;
import net.mygwt.ui.client.widget.Info;
import net.mygwt.ui.client.event.Listener;
-import net.mygwt.ui.client.event.Listener;
import net.mygwt.ui.client.event.BaseEvent;
import org.jboss.portal.presentation.ajax.client.Util;
@@ -54,6 +54,7 @@
import org.jboss.portal.presentation.ajax.client.layout.LayoutManager;
import org.jboss.portal.presentation.ajax.client.protocol.AjaxUpdateWindowStateAction;
import org.jboss.portal.presentation.ajax.client.protocol.Caller;
+import org.jboss.portal.presentation.ajax.client.protocol.AsyncActivateAction;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
@@ -61,11 +62,16 @@
*/
public class PortletWindow implements Caller
{
+ private static final int windowStateUpdate = 1;
+ private static final int getActivation = 2;
+ private static final int postActivation = 3;
+
/**
*
*/
private AjaxUIWindow window = null;
private String newWindowState = null;
+ private int requestType = 0;
/**
*
@@ -95,6 +101,7 @@
ContentPanel portletWindow = new ContentPanel(Style.HEADER);
portletWindow.setId(windowName);
+ portletWindow.layoutOnChange = true;
//Setup listeners
//Event Listener for the decoration components like
@@ -145,56 +152,16 @@
{
HTML windowContent = new HTML(this.window.getContent());
portletWindow.add(windowContent);
+
+ //Event Listener for actions perfomed inside the portlet window content
+ //itself. Used for performing Partial Refresh of a Portal Page
+ ClickListener contentListener = new ContentListener();
+ windowContent.addClickListener(contentListener);
}
- return portletWindow;
-
- //Event Listener for actions perfomed inside the portlet window content
- //itself. Used for performing Partial Refresh of a Portal Page
- /*ClickListener contentListener = new ClickListener()
- {
- public void onClick(Widget sender)
- {
- Event event = DOM.eventGetCurrentEvent();
- Element target = DOM.eventGetTarget(event);
-
- if(target.toString().toUpperCase().trim().indexOf("</A>") !=
-1)
- {
- String link = DOM.getElementAttribute(target, "HREF");
-
- //A link inside the portlet window was clicked
- //Load its content asynchronously inside this window
- boolean isPartialRefreshAllowed = isPartialRefreshAllowed(link);
- if(isPartialRefreshAllowed)
- {
- DOM.eventPreventDefault(event);
- handlePartialRefreshLink(link, sender);
- }
- }
- else if(target.toString().toUpperCase().trim().indexOf("INPUT") !=
-1 &&
- target.toString().toUpperCase().trim().indexOf("SUBMIT") !=
-1
- )
- {
- Element currentForm = DOM.getParent(target);
- String enctype = DOM.getElementAttribute(currentForm,
"enctype");
- String action = DOM.getElementAttribute(currentForm, "action");
- boolean isPartialRefreshAllowed = isPartialRefreshAllowed(action);
- if((isPartialRefreshAllowed) && (enctype == null ||
!enctype.equals("multipart/form-data")))
- {
- DOM.eventPreventDefault(event);
-
- //Call a native javascript function here
- String method = DOM.getElementAttribute(currentForm,
"method");
- String serializedForm = serializeForm(currentForm);
-
- handlePartialRefreshForm(action, method, serializedForm, sender);
- }
- }
- }
- };
- windowContent.addClickListener(contentListener);*/
+ return portletWindow;
}
-
+
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
/**
*
*/
@@ -202,29 +169,40 @@
{
if(result instanceof AjaxUIPage)
{
- boolean valid = this.validateNewWindowState();
- if(valid)
+ if(requestType == PortletWindow.windowStateUpdate)
{
- this.refresh();
- if(this.newWindowState.equals(AjaxUIWindow.NORMAL))
- {
- LayoutManager.normal(this.getName());
- }
- else if(this.newWindowState.equals(AjaxUIWindow.MAXIMIZE))
- {
- LayoutManager.maximize(this.getName());
+ boolean valid = this.validateNewWindowState();
+ if(valid)
+ {
+ this.refresh();
+ if(this.newWindowState.equals(AjaxUIWindow.NORMAL))
+ {
+ LayoutManager.normal(this.getName());
+ }
+ else if(this.newWindowState.equals(AjaxUIWindow.MAXIMIZE))
+ {
+ LayoutManager.maximize(this.getName());
+ }
+ else if(this.newWindowState.equals(AjaxUIWindow.MINIMIZE))
+ {
+ LayoutManager.minimize(this.getName());
+ }
}
- else if(this.newWindowState.equals(AjaxUIWindow.MINIMIZE))
- {
- LayoutManager.minimize(this.getName());
+ else
+ {
+ //Do something to handle this situation in a user-friendly manner
+ //Probably just laying out the current state of the page
+ Util.displayPortalPage();
}
}
- else
+ else if(requestType == PortletWindow.getActivation)
{
- //Do something to handle this situation in a user-friendly manner
- //Probably just laying out the current state of the page
Util.displayPortalPage();
}
+ else if(requestType == PortletWindow.postActivation)
+ {
+ Util.displayPortalPage();
+ }
}
//local state cleanup
@@ -263,183 +241,52 @@
this.window = (AjaxUIWindow)displayedPage.getChild(this.getName());
}
-
- /**
- *
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- *
- */
- private class PortletWindowListener implements Listener
- {
- /**
- *
- */
- private PortletWindow portletWindow = null;
- /**
- *
- * @param portletWindow
- */
- private PortletWindowListener(PortletWindow portletWindow)
- {
- this.portletWindow = portletWindow;
- }
-
- /**
- *
- * @param event
- */
- public void handleEvent(BaseEvent event)
- {
- IconButton cour = (IconButton)event.widget;
- String id = cour.getId();
- String windowName = id.substring(0, id.indexOf(':'));
- String action = id.substring(id.indexOf(':')+1);
-
- //Process the action performed on the window
- if(action.equals(AjaxUIWindow.NORMAL))
- {
- AjaxUpdateWindowStateAction stateAction = new
AjaxUpdateWindowStateAction(this.portletWindow.window.getId(), AjaxUIWindow.NORMAL);
- newWindowState = AjaxUIWindow.NORMAL;
- stateAction.execute(this.portletWindow);
- }
- else if(action.equals(AjaxUIWindow.MAXIMIZE))
- {
- AjaxUpdateWindowStateAction stateAction = new
AjaxUpdateWindowStateAction(this.portletWindow.window.getId(), AjaxUIWindow.MAXIMIZE);
- newWindowState = AjaxUIWindow.MAXIMIZE;
- stateAction.execute(this.portletWindow);
- }
- else if(action.equals(AjaxUIWindow.MINIMIZE))
- {
- AjaxUpdateWindowStateAction stateAction = new
AjaxUpdateWindowStateAction(this.portletWindow.window.getId(), AjaxUIWindow.MINIMIZE);
- newWindowState = AjaxUIWindow.MINIMIZE;
- stateAction.execute(this.portletWindow);
- }
- else if(action.equals("save"))
- {
- Info.show("Save", "Loading Save Mode....", "Loading
Save Mode....");
- }
- else if(action.equals("help"))
- {
- Info.show("Help", "Loading Help Mode....", "Loading
Help Mode....");
- }
- }
- }
-
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
+
//-------------------------------------------------------------------------------------------------------------------------------------------------------------
/**
*
- * @param window
- * @param newState
- */
- /*private void handleWindowStateChanged(String window, String newState)
- {
- PortletServiceAsync portletService =
(PortletServiceAsync)GWT.create(PortletService.class);
-
((ServiceDefTarget)portletService).setServiceEntryPoint(GWT.getModuleBaseURL()+"/portalrpc");
-
- AsyncCallback callback = new AsyncCallback()
- {
- public void onSuccess(Object result)
- {
- Page portalPage = (Page)result;
- displayPortalPage(portalPage);
- }
-
- public void onFailure(Throwable caught)
- {
- }
- };
-
- portletService.setState(window, newState, callback);
- }*/
-
- /**
- *
- * @param window
- * @param newState
- */
- /*private void handleWindowModeChanged(String window, String newMode)
- {
- PortletServiceAsync portletService =
(PortletServiceAsync)GWT.create(PortletService.class);
-
((ServiceDefTarget)portletService).setServiceEntryPoint(GWT.getModuleBaseURL()+"/portalrpc");
-
- AsyncCallback callback = new AsyncCallback()
- {
- public void onSuccess(Object result)
- {
- Page portalPage = (Page)result;
- displayPortalPage(portalPage);
- }
-
- public void onFailure(Throwable caught)
- {
- }
- };
-
- portletService.setMode(window, newMode, callback);
- }*/
-
- /**
- *
* @param url
* @param portletWindow
*/
- /*private void handlePartialRefreshLink(String url, Widget windowContent)
+ private void handlePartialRefreshLink(String url, Widget windowContent)
{
- HTTPRequest.asyncGet(url, new ResponseTextHandlerImpl(windowContent));
- }*/
+ AsyncActivateAction action = new AsyncActivateAction(url);
+ this.requestType = PortletWindow.getActivation;
+ action.execute(this);
+ }
/**
*
* @param url
* @param portletWindow
*/
- /*private void handlePartialRefreshForm(String url, String method, String postData,
Widget windowContent)
+ private void handlePartialRefreshForm(String url, String method, String postData,
Widget windowContent)
{
- if(method.equalsIgnoreCase("post"))
+ if(postData != null && postData.trim().length() > 0)
{
- HTTPRequest.asyncPost(url, postData, new
ResponseTextHandlerImpl(windowContent));
- }
- else if(method.equalsIgnoreCase("get"))
- {
- if(postData != null && postData.trim().length() > 0)
+ if(url.indexOf('?') == -1)
{
url = url + "?" + postData;
}
- HTTPRequest.asyncGet(url, new ResponseTextHandlerImpl(windowContent));
+ else
+ {
+ url = url + "&" + postData;
+ }
}
- }*/
-
- /**
- *
- * @author soshah
- *
- */
- /*private class ResponseTextHandlerImpl implements ResponseTextHandler
- {
- private Widget windowContent = null;
+ AsyncActivateAction action = new AsyncActivateAction(url);
+ this.requestType = PortletWindow.getActivation;
+ action.execute(this);
+ }
- public ResponseTextHandlerImpl(Widget windowContent)
- {
- this.windowContent = windowContent;
- }
- public void onCompletion(String responseText)
- {
- HTML html = new HTML(responseText);
- Panel window = (Panel)this.windowContent.getParent();
- this.windowContent.removeFromParent();
- window.add(html);
- }
- }*/
-
/**
*
* @param url
* @return
*/
- /*private boolean isPartialRefreshAllowed(String url)
+ private boolean isPartialRefreshAllowed(String url)
{
String basePortalURL = GWT.getModuleBaseURL();
- String portalContext = "org.jboss.portal.uiserver.Portal"; //This is hard
coded for now, but must be populated from the Portal deployment environment
+ String portalContext = "presentation"; //This is hard coded for now, but
must be populated from the Portal deployment environment
//If Portal is installed at Root context, this value will be an empty string
if(url.startsWith(basePortalURL))
@@ -501,8 +348,8 @@
//If I get here, Async Page Refresh through the Portal should be allowed
return true;
- }
- }*/
+ }
+ }
/**
*
@@ -513,5 +360,115 @@
/*-{
var formData = $wnd.Form.serialize(currentForm);
return formData;
- }-*/;
+ }-*/;
+
//-----------------------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+ private class PortletWindowListener implements Listener
+ {
+ /**
+ *
+ */
+ private PortletWindow portletWindow = null;
+
+ /**
+ *
+ * @param portletWindow
+ */
+ private PortletWindowListener(PortletWindow portletWindow)
+ {
+ this.portletWindow = portletWindow;
+ }
+
+ /**
+ *
+ * @param event
+ */
+ public void handleEvent(BaseEvent event)
+ {
+ IconButton cour = (IconButton)event.widget;
+ String id = cour.getId();
+ String windowName = id.substring(0, id.indexOf(':'));
+ String action = id.substring(id.indexOf(':')+1);
+
+ //Process the action performed on the window
+ if(action.equals(AjaxUIWindow.NORMAL))
+ {
+ AjaxUpdateWindowStateAction stateAction = new
AjaxUpdateWindowStateAction(this.portletWindow.window.getId(), AjaxUIWindow.NORMAL);
+ newWindowState = AjaxUIWindow.NORMAL;
+ requestType = PortletWindow.windowStateUpdate;
+ stateAction.execute(this.portletWindow);
+ }
+ else if(action.equals(AjaxUIWindow.MAXIMIZE))
+ {
+ AjaxUpdateWindowStateAction stateAction = new
AjaxUpdateWindowStateAction(this.portletWindow.window.getId(), AjaxUIWindow.MAXIMIZE);
+ newWindowState = AjaxUIWindow.MAXIMIZE;
+ requestType = PortletWindow.windowStateUpdate;
+ stateAction.execute(this.portletWindow);
+ }
+ else if(action.equals(AjaxUIWindow.MINIMIZE))
+ {
+ AjaxUpdateWindowStateAction stateAction = new
AjaxUpdateWindowStateAction(this.portletWindow.window.getId(), AjaxUIWindow.MINIMIZE);
+ newWindowState = AjaxUIWindow.MINIMIZE;
+ requestType = PortletWindow.windowStateUpdate;
+ stateAction.execute(this.portletWindow);
+ }
+ else if(action.equals("save"))
+ {
+ Info.show("Save", "Loading Save Mode....", "Loading
Save Mode....");
+ }
+ else if(action.equals("help"))
+ {
+ Info.show("Help", "Loading Help Mode....", "Loading
Help Mode....");
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ private class ContentListener implements ClickListener
+ {
+ public void onClick(Widget sender)
+ {
+ Event event = DOM.eventGetCurrentEvent();
+ Element target = DOM.eventGetTarget(event);
+
+ if(target.toString().toUpperCase().trim().indexOf("</A>") !=
-1)
+ {
+ String link = DOM.getElementAttribute(target, "HREF");
+
+ //A link inside the portlet window was clicked
+ //Load its content asynchronously inside this window
+ boolean isPartialRefreshAllowed = isPartialRefreshAllowed(link.trim());
+ if(isPartialRefreshAllowed)
+ {
+ DOM.eventPreventDefault(event);
+ handlePartialRefreshLink(link.trim(), sender);
+ }
+ }
+ else if(target.toString().toUpperCase().trim().indexOf("INPUT") != -1
&&
+ target.toString().toUpperCase().trim().indexOf("SUBMIT") !=
-1
+ )
+ {
+ Element currentForm = DOM.getParent(target);
+ String enctype = DOM.getElementAttribute(currentForm, "enctype");
+ String action = DOM.getElementAttribute(currentForm, "action");
+ boolean isPartialRefreshAllowed = isPartialRefreshAllowed(action.trim());
+ if((isPartialRefreshAllowed) && (enctype == null ||
!enctype.equals("multipart/form-data")))
+ {
+ DOM.eventPreventDefault(event);
+
+ //Call a native javascript function here
+ String method = DOM.getElementAttribute(currentForm, "method");
+ String serializedForm = serializeForm(currentForm);
+
+ handlePartialRefreshForm(action.trim(), method, serializedForm, sender);
+ }
+ }
+ }
+ }
}
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java 2008-01-04
10:26:54 UTC (rev 9438)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/PresentationContextImpl.java 2008-01-06
06:33:29 UTC (rev 9439)
@@ -118,8 +118,12 @@
//
if (objectAction instanceof LinkActivation)
{
- StringBuffer portalRequestPath = new StringBuffer("/invoke");
- createPath(target, portalRequestPath);
+ //StringBuffer portalRequestPath = new StringBuffer("/invoke");
+ //createPath(target, portalRequestPath);
+
+ StringBuffer portalRequestPath = new StringBuffer();
+ portalRequestPath.append(targetId);
+
ServerURL url = new AbstractServerURL();
url.setPortalRequestPath(portalRequestPath.toString());
LinkActivation linkActivation = (LinkActivation)objectAction;
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java 2008-01-04
10:26:54 UTC (rev 9438)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/ajax/entry/PortalEntryPoint.java 2008-01-06
06:33:29 UTC (rev 9439)
@@ -3,7 +3,10 @@
import java.util.Map;
import java.util.List;
+import java.util.Iterator;
+import java.util.StringTokenizer;
import java.util.HashMap;
+import java.net.URLDecoder;
import javax.management.MBeanServer;
import javax.management.ObjectName;
@@ -151,7 +154,7 @@
* @param windowState
* @return
*/
- public ClientResponse asyncGet(String url, Map queryParams)
+ public ClientResponse asyncActivate(String uiObjectId, Map queryParams)
{
try
{
@@ -159,12 +162,15 @@
HttpServletRequest request = this.getThreadLocalRequest();
- if(queryParams.containsKey("windowstate"))
+ Map params = new HashMap();
+ for(Iterator itr=queryParams.keySet().iterator(); itr.hasNext();)
{
- String windowState = (String)queryParams.get("windowstate");
- queryParams.put("windowstate", new String[]{windowState});
+ String key = (String)itr.next();
+ String value = (String)queryParams.get(key);
+ params.put(key, new String[]{value});
}
- GetActivation get = new GetActivation(url, queryParams);
+
+ GetActivation get = new GetActivation(uiObjectId, params);
request.setAttribute("serverAction", get);
@@ -185,6 +191,53 @@
throw new RuntimeException(e);
}
}
+
+ /**
+ *
+ * @param url
+ * @return
+ */
+ public ClientResponse asyncActivate(String url)
+ {
+ try
+ {
+ Map queryParams = new HashMap();
+
+ //Parse the query parameters into a Map of name value pairs
+ if(url.indexOf('?') != -1)
+ {
+ String queryString = url.substring(url.indexOf('?')+1);
+ StringTokenizer st = new StringTokenizer(queryString, "&");
+ while(st.hasMoreTokens())
+ {
+ String token = st.nextToken();
+ int equalIndex = token.indexOf('=');
+ String name = token.substring(0, equalIndex);
+ String value = token.substring(equalIndex+1);
+ queryParams.put(name, URLDecoder.decode(value, "UTF-8"));
+ }
+ }
+
+ //Parse the UIObject id
+ String uiObjectId = null;
+ int invokeIndex = url.indexOf("presentation"); //hard coding the
portal deployment context for now
+ int endIndex = url.indexOf('?');
+ if(endIndex != -1)
+ {
+ uiObjectId = url.substring(invokeIndex+"presentation".length(),
endIndex);
+ }
+ else
+ {
+ uiObjectId = url.substring(invokeIndex+"presentation".length());
+ }
+
+ return this.asyncActivate(uiObjectId, queryParams);
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------
/**
*