Author: sohil.shah(a)jboss.com
Date: 2007-12-13 18:18:58 -0500 (Thu, 13 Dec 2007)
New Revision: 9342
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Util.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/Caller.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/ClientAction.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/UIObjectAction.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/ViewUIObjectAction.java
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Portal.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/AjaxUIController.java
Log:
ajax user agent refactoring
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Portal.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Portal.java 2007-12-13
23:01:28 UTC (rev 9341)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Portal.java 2007-12-13
23:18:58 UTC (rev 9342)
@@ -22,24 +22,11 @@
******************************************************************************/
package org.jboss.portal.presentation.ajax.client;
-import java.util.List;
-import java.util.ArrayList;
-
-import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.EntryPoint;
-import com.google.gwt.user.client.rpc.ServiceDefTarget;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-
-import org.jboss.portal.presentation.ajax.client.service.PortalRPC;
-import org.jboss.portal.presentation.ajax.client.service.PortalRPCAsync;
-import org.jboss.portal.presentation.ajax.client.widget.PortletWindow;
-import org.jboss.portal.presentation.ajax.client.layout.LayoutManager;
-import org.jboss.portal.presentation.ajax.client.model.UIContext;
import org.jboss.portal.presentation.ajax.client.model.UIPage;
-import org.jboss.portal.presentation.ajax.client.model.UIPortal;
-import org.jboss.portal.presentation.ajax.client.model.UIWindow;
-import org.jboss.portal.presentation.ajax.client.model.UIObject;
+import org.jboss.portal.presentation.ajax.client.protocol.Caller;
+import org.jboss.portal.presentation.ajax.client.protocol.ViewUIObjectAction;
/**
* This is the Entry Point of the client-side Ajax agent of the Presentation Framework
@@ -47,52 +34,26 @@
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
*
*/
-public class Portal implements EntryPoint
+public class Portal implements EntryPoint, Caller
{
/**
* This is the entry point method.
*/
public void onModuleLoad()
{
- PortalRPCAsync portalRPC = (PortalRPCAsync)GWT.create(PortalRPC.class);
-
((ServiceDefTarget)portalRPC).setServiceEntryPoint(GWT.getModuleBaseURL()+"/portalrpc");
- AsyncCallback callback = new AsyncCallback()
- {
- public void onSuccess(Object result)
- {
- UIObject uiObject = (UIObject)result;
- Session.getInstance().getUiContext().addObject(uiObject);
- displayPortalPage((UIPage)uiObject);
- }
-
- public void onFailure(Throwable caught)
- {
- }
- };
- portalRPC.loadObject("/default/default", callback);
- }
+ //Load the default page of the default portal upon loading the user agent
+ ViewUIObjectAction action = new ViewUIObjectAction("/default/default");
+ action.execute(this);
+ }
/**
*
- * @param portalPage
*/
- private void displayPortalPage(UIPage portalPage)
- {
- //Dispalying the fully aggregated page
- List windows = portalPage.getChildren();
- if(windows != null)
+ public void callback(Object result)
+ {
+ if(result instanceof UIPage)
{
- List displayWindows = new ArrayList();
- for(int i=0; i<windows.size(); i++)
- {
- UIWindow pageWindow = (UIWindow)windows.get(i);
- if(pageWindow.isVisible())
- {
- PortletWindow portletWindow = new PortletWindow(pageWindow);
- displayWindows.add(portletWindow);
- }
- }
- LayoutManager.doLayout(displayWindows);
- }
- }
+ Util.displayPortalPage((UIPage)result);
+ }
+ }
}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Util.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Util.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/Util.java 2007-12-13
23:18:58 UTC (rev 9342)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.portal.presentation.ajax.client.layout.LayoutManager;
+import org.jboss.portal.presentation.ajax.client.model.UIPage;
+import org.jboss.portal.presentation.ajax.client.model.UIWindow;
+import org.jboss.portal.presentation.ajax.client.widget.PortletWindow;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class Util
+{
+ /**
+ *
+ * @param portalPage
+ */
+ public static void displayPortalPage(UIPage portalPage)
+ {
+ //Dispalying the fully aggregated page
+ List windows = portalPage.getChildren();
+ if(windows != null)
+ {
+ List displayWindows = new ArrayList();
+ for(int i=0; i<windows.size(); i++)
+ {
+ UIWindow pageWindow = (UIWindow)windows.get(i);
+ if(pageWindow.isVisible())
+ {
+ PortletWindow portletWindow = new PortletWindow(pageWindow);
+ displayWindows.add(portletWindow);
+ }
+ }
+ LayoutManager.doLayout(displayWindows);
+ }
+ }
+}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/Caller.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/Caller.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/Caller.java 2007-12-13
23:18:58 UTC (rev 9342)
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public interface Caller
+{
+ /**
+ *
+ * @param result
+ */
+ public void callback(Object result);
+}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/ClientAction.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/ClientAction.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/ClientAction.java 2007-12-13
23:18:58 UTC (rev 9342)
@@ -0,0 +1,32 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public abstract class ClientAction
+{
+ public abstract void execute(Caller caller);
+}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/UIObjectAction.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/UIObjectAction.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/UIObjectAction.java 2007-12-13
23:18:58 UTC (rev 9342)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * 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;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public abstract class UIObjectAction extends ClientAction
+{
+ /**
+ *
+ */
+ private final String targetId;
+
+ /**
+ *
+ * @param targetId
+ */
+ public UIObjectAction(String targetId)
+ {
+ this.targetId = targetId;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getTargetId()
+ {
+ return targetId;
+ }
+}
Added:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/ViewUIObjectAction.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/ViewUIObjectAction.java
(rev 0)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/ajax/client/protocol/ViewUIObjectAction.java 2007-12-13
23:18:58 UTC (rev 9342)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * 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.UIObject;
+import org.jboss.portal.presentation.ajax.client.service.PortalRPC;
+import org.jboss.portal.presentation.ajax.client.service.PortalRPCAsync;
+
+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 ViewUIObjectAction extends UIObjectAction
+{
+ /**
+ *
+ * @param targetId
+ */
+ public ViewUIObjectAction(String targetId)
+ {
+ super(targetId);
+ }
+
+ /**
+ *
+ */
+ 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)
+ {
+ UIObject uiObject = (UIObject)result;
+ Session.getInstance().getUiContext().addObject(uiObject);
+ caller.callback(uiObject);
+ }
+
+ public void onFailure(Throwable caught)
+ {
+ }
+ };
+ portalRPC.loadObject(this.getTargetId(), callback);
+ }
+}
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/AjaxUIController.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/AjaxUIController.java 2007-12-13
23:01:28 UTC (rev 9341)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/client/controller/AjaxUIController.java 2007-12-13
23:18:58 UTC (rev 9342)
@@ -121,15 +121,7 @@
{
ShowUIObjectResponse show = (ShowUIObjectResponse)serverResponse;
String targetId = show.getTargetId();
-
- //Load the objects in the UITree
- UIObject uiObject = presentationContext.getUIContext().getObject(targetId);
-
- if(uiObject instanceof UIPage)
- {
- //
- render(invocation, presentationContext, targetId);
- }
+ render(invocation, presentationContext, targetId);
}
}
catch(Exception e)