Author: chris.laprun(a)jboss.com
Date: 2009-10-29 15:44:27 -0400 (Thu, 29 Oct 2009)
New Revision: 444
Modified:
portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java
Log:
- Fixed editing the portlet in the page editing mode that wasn't working in the WSRP
case.
Modified:
portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java
===================================================================
---
portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java 2009-10-29
18:14:44 UTC (rev 443)
+++
portal/branches/wsrp-integration/webui/portal/src/main/java/org/exoplatform/portal/webui/application/UIPortletForm.java 2009-10-29
19:44:27 UTC (rev 444)
@@ -24,6 +24,8 @@
import org.exoplatform.portal.pc.ExoPortletState;
import org.exoplatform.portal.pom.spi.portlet.Preference;
import org.exoplatform.portal.pom.spi.portlet.Preferences;
+import org.exoplatform.portal.pom.spi.wsrp.WSRP;
+import org.exoplatform.portal.pom.spi.wsrp.WSRPPortletStateType;
import org.exoplatform.portal.portlet.PortletExceptionHandleService;
import org.exoplatform.portal.skin.SkinService;
import org.exoplatform.portal.webui.util.Util;
@@ -63,6 +65,8 @@
import org.gatein.pc.api.invocation.response.ErrorResponse;
import org.gatein.pc.api.invocation.response.FragmentResponse;
import org.gatein.pc.api.invocation.response.PortletInvocationResponse;
+import org.gatein.pc.api.spi.InstanceContext;
+import org.gatein.pc.api.state.AccessMode;
import org.gatein.pc.api.state.PropertyChange;
import org.gatein.pc.portlet.impl.spi.AbstractClientContext;
import org.gatein.pc.portlet.impl.spi.AbstractPortalContext;
@@ -74,6 +78,7 @@
import javax.portlet.PortletMode;
import javax.servlet.http.Cookie;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.ResourceBundle;
@@ -163,21 +168,36 @@
{
PortalRequestContext prcontext =
(PortalRequestContext)WebuiRequestContext.getCurrentInstance();
prcontext.setFullRender(true);
- PortletInvoker portletInvoker = getApplicationComponent(PortletInvoker.class);
- StatefulPortletContext<ExoPortletState> portletContext =
uiPortlet_.getPortletContext();
+ StatefulPortletContext portletContext = uiPortlet_.getPortletContext();
ExoPortletInvocationContext portletInvocationContext = new
ExoPortletInvocationContext(prcontext, uiPortlet_);
- List<Cookie> requestCookies = new ArrayList<Cookie>();
- for (Cookie cookie : prcontext.getRequest().getCookies())
- {
- requestCookies.add(cookie);
- }
+ List<Cookie> requestCookies = new
ArrayList<Cookie>(Arrays.asList(prcontext.getRequest().getCookies()));
RenderInvocation renderInvocation = new
RenderInvocation(portletInvocationContext);
renderInvocation.setClientContext(new
AbstractClientContext(prcontext.getRequest(), requestCookies));
renderInvocation.setServerContext(new
AbstractServerContext(prcontext.getRequest(), prcontext.getResponse()));
- renderInvocation.setInstanceContext(new
ExoPortletInstanceContext(portletContext.getState().getPortletId()));
+
+
+ // instance context
+ InstanceContext instanceContext;
+ if (portletContext.getType() instanceof WSRPPortletStateType)
+ {
+ WSRP wsrp = (WSRP)portletContext.getState();
+ AccessMode accessMode = AccessMode.CLONE_BEFORE_WRITE;
+ if (wsrp.isCloned())
+ {
+ accessMode = AccessMode.READ_WRITE;
+ }
+ instanceContext = new ExoPortletInstanceContext(wsrp.getPortletId(),
accessMode);
+ }
+ else
+ {
+ ExoPortletState exo = (ExoPortletState)portletContext.getState();
+ instanceContext = new ExoPortletInstanceContext(exo.getPortletId());
+ }
+ renderInvocation.setInstanceContext(instanceContext);
+
renderInvocation.setUserContext(new
AbstractUserContext(prcontext.getRequest()));
renderInvocation.setWindowContext(new
AbstractWindowContext(uiPortlet_.getWindowId()));
renderInvocation.setPortalContext(new
AbstractPortalContext(Collections.singletonMap(