JBoss Portal SVN: r6555 - trunk/core-admin/src/main/org/jboss/portal/core/faces.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-06 11:51:17 -0500 (Tue, 06 Mar 2007)
New Revision: 6555
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java
Log:
added more todos
Modified: trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java 2007-03-06 16:48:17 UTC (rev 6554)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java 2007-03-06 16:51:17 UTC (rev 6555)
@@ -49,12 +49,20 @@
import java.util.Set;
/**
- * @todo :
+ * @todo:
* - add validation of initial mode and window state against the supported values
* - add validation of mode and window state on portlet events against the supported values
* - add handling of non expected results from render and process action
* - add handling when instance does not exist (probably show the nested content of the tag as markup)
*
+ * @todo but less important:
+ * - integrate user profile
+ * - clean up the facelet portlet handler
+ * - make a JSP tag
+ *
+ * @todo later:
+ * - form rewriting so it can work in a JSF form
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
17 years, 4 months
JBoss Portal SVN: r6554 - trunk/core-admin/src/main/org/jboss/portal/core/faces.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-06 11:48:17 -0500 (Tue, 06 Mar 2007)
New Revision: 6554
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java
Log:
added some todo for future
Modified: trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java 2007-03-06 16:41:28 UTC (rev 6553)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java 2007-03-06 16:48:17 UTC (rev 6554)
@@ -49,6 +49,12 @@
import java.util.Set;
/**
+ * @todo :
+ * - add validation of initial mode and window state against the supported values
+ * - add validation of mode and window state on portlet events against the supported values
+ * - add handling of non expected results from render and process action
+ * - add handling when instance does not exist (probably show the nested content of the tag as markup)
+ *
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
@@ -58,28 +64,28 @@
/** The portlet instance id. */
private String instanceId;
- /** . */
+ /** The event listener if not null. */
private MethodBinding portletListener;
- /** . */
+ /** The supported window states. */
private Set supportedWindowStates;
- /** . */
+ /** The supported modes. */
private Set supportedModes;
- /** . */
+ /** The initial window state value if not null, otherwise NORMAL is used. */
private String initialWindowState;
- /** . */
+ /** The initial mode value if not null, otherwise VIEW is used. */
private String initialMode;
- /** . */
+ /** The internal nav state. */
private PortletParameters internalNavState;
- /** . */
+ /** The internal window state value. */
private WindowState internalWindowState;
- /** . */
+ /** The internal mode value. */
private Mode internalMode;
public String getInstanceId()
17 years, 4 months
JBoss Portal SVN: r6553 - in trunk/core-admin/src: main/org/jboss/portal/core/faces and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-06 11:41:28 -0500 (Tue, 06 Mar 2007)
New Revision: 6553
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml
Log:
- use edit_content mode for the portlet
- correct a few bugs
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java 2007-03-06 16:26:19 UTC (rev 6552)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java 2007-03-06 16:41:28 UTC (rev 6553)
@@ -39,6 +39,7 @@
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletURL;
+import javax.portlet.PortletMode;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
@@ -51,6 +52,9 @@
{
/** . */
+ private static final PortletMode EDIT_CONTENT = new PortletMode("edit_content");
+
+ /** . */
private InstanceContainer instanceContainer;
public void init() throws PortletException
@@ -61,80 +65,86 @@
public void processAction(ActionRequest req, ActionResponse resp) throws PortletException, PortletSecurityException, IOException
{
- String uri = req.getParameter("uri");
- if (uri != null)
+ if (req.getPortletMode().equals(EDIT_CONTENT))
{
- resp.setRenderParameter("uri", uri);
+ String uri = req.getParameter("uri");
+ if (uri != null)
+ {
+ resp.setRenderParameter("uri", uri);
+ }
}
}
public void render(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
{
- String selectedURI = req.getParameter("uri");
-
- //
- PortletURL actionURL = resp.createActionURL();
-
- //
- resp.setContentType("text/html");
- PrintWriter writer = resp.getWriter();
-
- // load insances this user has access to.
- List available_instances = (List)instanceContainer.getDefinitions();
- Instance selectedInstance = null;
- writer.print("<form action=\"");
- writer.print(actionURL);
- writer.print("\" method=\"post\">\n");
- writer.println("<select name=\"uri\"size=\"20\">\n");
- for (int i = 0; i < available_instances.size(); i++)
+ if (req.getPortletMode().equals(EDIT_CONTENT))
{
- Instance instance = (Instance)available_instances.get(i);
+ String selectedURI = req.getParameter("uri");
//
- writer.print("<option value=\"");
- writer.print(instance.getId());
- writer.print("\"");
+ PortletURL actionURL = resp.createActionURL();
//
- if (instance.getId().equals(selectedURI))
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+
+ // load insances this user has access to.
+ List available_instances = (List)instanceContainer.getDefinitions();
+ Instance selectedInstance = null;
+ writer.print("<form action=\"");
+ writer.print(actionURL);
+ writer.print("\" method=\"post\">\n");
+ writer.println("<select name=\"uri\"size=\"20\">\n");
+ for (int i = 0; i < available_instances.size(); i++)
{
- selectedInstance = instance;
- writer.print(" selected=\"selected\"");
+ Instance instance = (Instance)available_instances.get(i);
+
+ //
+ writer.print("<option value=\"");
+ writer.print(instance.getId());
+ writer.print("\"");
+
+ //
+ if (instance.getId().equals(selectedURI))
+ {
+ selectedInstance = instance;
+ writer.print(" selected=\"selected\"");
+ }
+
+ //
+ writer.print(">");
+ writer.print(instance.getId());
+ writer.println("</option>\n");
}
+ writer.println("</select>");
+ writer.println("<input name=\"select\" value=\"Select\" type=\"submit\"/>");
+ writer.print("</form>");
//
- writer.print(">");
- writer.print(instance.getId());
- writer.println("</option>\n");
- }
- writer.println("</select>");
- writer.println("<input name=\"select\" value=\"Select\" type=\"submit\"/>");
- writer.print("</form>");
-
- //
- if (selectedInstance != null)
- {
- writer.print("<div class=\"portlet-font\" style=\"float:left\">");
- writer.print("<div><span class=\"portlet-form-field-label\">Portlet instance:</span>" + selectedURI + "</div>");
- try
+ if (selectedInstance != null)
{
- Portlet portlet = selectedInstance.getPortlet();
- if (portlet != null)
+ writer.print("<div class=\"portlet-font\" style=\"float:left\">");
+ writer.print("<div><span class=\"portlet-form-field-label\">Portlet instance:</span>" + selectedURI + "</div>");
+ try
{
- MetaInfo metaInfo = portlet.getInfo().getMeta();
- writer.print("<div><span class=\"portlet-form-field-label\">Portlet name:</span>" + metaInfo.getMetaValue(MetaInfo.DISPLAY_NAME).getDefaultString() + "</div>");
- writer.print("<div><span class=\"portlet-form-field-label\">Portlet description:</span>" + metaInfo.getMetaValue(MetaInfo.DESCRIPTION).getDefaultString() + "</div>");
- writer.print("<div><span class=\"portlet-form-field-label\">Portlet title:</span>" + metaInfo.getMetaValue(MetaInfo.TITLE).getDefaultString() + "</div>");
- writer.print("<div><span class=\"portlet-form-field-label\">Portlet keywords:</span>" + metaInfo.getMetaValue(MetaInfo.KEYWORDS).getDefaultString() + "</div>");
+ Portlet portlet = selectedInstance.getPortlet();
+ if (portlet != null)
+ {
+ MetaInfo metaInfo = portlet.getInfo().getMeta();
+ writer.print("<div><span class=\"portlet-form-field-label\">Portlet name:</span>" + metaInfo.getMetaValue(MetaInfo.DISPLAY_NAME).getDefaultString() + "</div>");
+ writer.print("<div><span class=\"portlet-form-field-label\">Portlet description:</span>" + metaInfo.getMetaValue(MetaInfo.DESCRIPTION).getDefaultString() + "</div>");
+ writer.print("<div><span class=\"portlet-form-field-label\">Portlet title:</span>" + metaInfo.getMetaValue(MetaInfo.TITLE).getDefaultString() + "</div>");
+ writer.print("<div><span class=\"portlet-form-field-label\">Portlet keywords:</span>" + metaInfo.getMetaValue(MetaInfo.KEYWORDS).getDefaultString() + "</div>");
+ }
}
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
}
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
+
+ //
+ writer.close();
}
-
- //
- writer.close();
}
}
Modified: trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java 2007-03-06 16:26:19 UTC (rev 6552)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java 2007-03-06 16:41:28 UTC (rev 6553)
@@ -326,12 +326,17 @@
}
//
- Object values[] = new Object[5];
+ Object values[] = new Object[10];
values[0] = super.saveState(faces);
values[1] = instanceId;
values[2] = opaqueValue;
values[3] = saveAttachedState(faces, portletListener);
- values[4] = supportedModes;
+ values[4] = supportedWindowStates;
+ values[5] = supportedModes;
+ values[6] = initialWindowState;
+ values[7] = initialMode;
+ values[8] = internalNavState;
+ values[9] = internalMode;
return values;
}
@@ -345,7 +350,12 @@
instanceId = (String)values[1];
internalNavState = serializedNavState != null ? new PortletParametersStateString(serializedNavState).getParameters() : null;
portletListener = (MethodBinding)restoreAttachedState(faces, values[3]);
- supportedModes = (Set)values[4];
+ supportedWindowStates = (Set)values[4];
+ supportedModes = (Set)values[5];
+ initialWindowState = (String)values[6];
+ initialMode = (String)values[7];
+ internalNavState = (PortletParameters)values[8];
+ internalMode = (Mode)values[9];
}
public void decode(FacesContext faces)
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml 2007-03-06 16:26:19 UTC (rev 6552)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml 2007-03-06 16:41:28 UTC (rev 6553)
@@ -103,9 +103,9 @@
<jbp:portlet
instanceId="#{portalobjectmgr.selectedContentEditorInstance}"
actionListener="#{portalobjectmgr.processEvent}"
- supportedModes="view"
+ supportedModes="edit_content"
supportedWindowStates="normal"
- initialMode="view"
+ initialMode="edit_content"
initialWindowState="normal"/>
</div>
17 years, 4 months
JBoss Portal SVN: r6552 - in trunk/core-admin/src: resources/portal-admin-war/WEB-INF and 1 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-06 11:26:19 -0500 (Tue, 06 Mar 2007)
New Revision: 6552
Added:
trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletHandler.java
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFPortalContext.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletActionEvent.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletRenderEvent.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portal.taglib.xml
Log:
added support for window state / mode / supported window states / supported modes in the jsf protlet stuff
Modified: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java 2007-03-06 14:51:39 UTC (rev 6551)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java 2007-03-06 16:26:19 UTC (rev 6552)
@@ -100,7 +100,7 @@
this.uiportlet = uiportlet;
//
- this.portalContext = new JSFPortalContext(faces);
+ this.portalContext = new JSFPortalContext(faces, uiportlet);
this.requestContext = new AbstractRequestContext(clientRequest, clientResponse);
this.securityContext = new JSFSecurityContext(faces);
this.userContext = new JSFUserContext(faces);
Modified: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFPortalContext.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFPortalContext.java 2007-03-06 14:51:39 UTC (rev 6551)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFPortalContext.java 2007-03-06 16:26:19 UTC (rev 6552)
@@ -31,6 +31,8 @@
import java.util.Set;
import java.util.Map;
import java.util.Collections;
+import java.util.Iterator;
+import java.util.HashSet;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -40,26 +42,72 @@
{
/** . */
- private static final Set modes = Collections.unmodifiableSet(Tools.toSet(new Mode[]{Mode.VIEW,Mode.EDIT,Mode.HELP}));
+ private static final Set defaultModes = Collections.unmodifiableSet(Tools.toSet(new Mode[]{Mode.VIEW,Mode.EDIT,Mode.HELP}));
/** . */
- private static final Set windowStates = Collections.unmodifiableSet(Tools.toSet(new WindowState[]{WindowState.NORMAL,WindowState.MINIMIZED,WindowState.MAXIMIZED}));
+ private static final Set defaultWindowStates = Collections.unmodifiableSet(Tools.toSet(new WindowState[]{WindowState.NORMAL,WindowState.MINIMIZED,WindowState.MAXIMIZED}));
/** . */
private final FacesContext faces;
- public JSFPortalContext(FacesContext faces)
+ /** . */
+ private final UIPortlet portlet;
+
+ /** . */
+ private Set modes;
+
+ /** . */
+ private Set windowStates;
+
+ public JSFPortalContext(FacesContext faces, UIPortlet portlet)
{
this.faces = faces;
+ this.portlet = portlet;
}
public Set getWindowStates()
{
+ if (windowStates == null)
+ {
+ Set tmp = portlet.getSupportedWindowStates();
+ if (tmp != null)
+ {
+ windowStates = new HashSet(tmp.size());
+ for (Iterator i = tmp.iterator();i.hasNext();)
+ {
+ String windowStateName = (String)i.next();
+ WindowState windowState = WindowState.create(windowStateName);
+ windowStates.add(windowState);
+ }
+ }
+ else
+ {
+ windowStates = defaultWindowStates;
+ }
+ }
return windowStates;
}
public Set getModes()
{
+ if (modes == null)
+ {
+ Set tmp = portlet.getSupportedModes();
+ if (tmp != null)
+ {
+ modes = new HashSet(tmp.size());
+ for (Iterator i = tmp.iterator();i.hasNext();)
+ {
+ String modeName = (String)i.next();
+ Mode windowState = Mode.create(modeName);
+ modes.add(windowState);
+ }
+ }
+ else
+ {
+ modes = defaultModes;
+ }
+ }
return modes;
}
Modified: trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletActionEvent.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletActionEvent.java 2007-03-06 14:51:39 UTC (rev 6551)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletActionEvent.java 2007-03-06 16:26:19 UTC (rev 6552)
@@ -46,12 +46,30 @@
/** . */
private final PortletParameters interactionState;
- public PortletActionEvent(UIComponent uiComponent, PortletParameters interactionState)
+ /** . */
+ private Mode mode;
+
+ /** . */
+ private WindowState windowState;
+
+ PortletActionEvent(UIComponent uiComponent, PortletParameters interactionState, Mode mode, WindowState windowState)
{
super(uiComponent);
//
+ if (mode == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (windowState == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ //
this.interactionState = interactionState;
+ this.mode = mode;
+ this.windowState = windowState;
}
public Map getParameterMap()
@@ -59,6 +77,34 @@
return interactionState;
}
+ public String getMode()
+ {
+ return mode.toString();
+ }
+
+ public void setMode(String mode)
+ {
+ if (mode == null)
+ {
+ throw new IllegalArgumentException("No mode provided");
+ }
+ this.mode = Mode.create(mode);
+ }
+
+ public String getWindowState()
+ {
+ return windowState.toString();
+ }
+
+ public void setWindowState(String windowState)
+ {
+ if (mode == null)
+ {
+ throw new IllegalArgumentException("No window state provided");
+ }
+ this.windowState = WindowState.create(windowState);
+ }
+
void execute(FacesContext faces)
{
UIPortlet uiportlet = (UIPortlet)getComponent();
@@ -74,11 +120,25 @@
//
try
{
- PortletInvocationResponse pir = invocation.action(instance, Mode.VIEW, WindowState.NORMAL, new PortletParametersStateString(interactionState));
+ PortletInvocationResponse pir = invocation.action(instance, mode, windowState, new PortletParametersStateString(interactionState));
if (pir instanceof RenderResponse)
{
RenderResponse render = (RenderResponse)pir;
- uiportlet.setNavState(((PortletParametersStateString)render.getNavigationalState()).getParameters());
+
+ //
+ uiportlet.setInternalNavState(((PortletParametersStateString)render.getNavigationalState()).getParameters());
+
+ //
+ if (render.getWindowState() != null)
+ {
+ uiportlet.setInternalWindowState(render.getWindowState());
+ }
+
+ //
+ if (render.getMode() != null)
+ {
+ uiportlet.setInternalMode(render.getMode());
+ }
}
}
catch (PortletInvokerException e)
Added: trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletHandler.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletHandler.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletHandler.java 2007-03-06 16:26:19 UTC (rev 6552)
@@ -0,0 +1,106 @@
+/******************************************************************************
+ * 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.core.faces;
+
+import com.sun.facelets.tag.jsf.ComponentHandler;
+import com.sun.facelets.tag.jsf.ComponentConfig;
+import com.sun.facelets.tag.MetaRuleset;
+import com.sun.facelets.tag.MetaRule;
+import com.sun.facelets.tag.Metadata;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.MetadataTarget;
+import com.sun.facelets.FaceletContext;
+
+import java.util.Set;
+import java.util.HashSet;
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorManager;
+
+import org.jboss.portal.common.util.Tools;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletHandler extends ComponentHandler
+{
+ public PortletHandler(ComponentConfig config)
+ {
+ super(config);
+ }
+
+
+ protected MetaRuleset createMetaRuleset(Class type)
+ {
+ MetaRuleset mr = super.createMetaRuleset(type);
+
+ //
+ mr.addRule(new MetaRule()
+ {
+ public Metadata applyRule(String name, TagAttribute attribute, MetadataTarget meta)
+ {
+ if ("supportedModes".equals(name))
+ {
+ if (attribute.isLiteral())
+ {
+ String s = attribute.getValue();
+ PropertyEditor editor = PropertyEditorManager.findEditor(String[].class);
+ editor.setAsText(s);
+ String[] values = (String[])editor.getValue();
+ final Set set = Tools.toSet(values);
+ return new Metadata()
+ {
+ public void applyMetadata(FaceletContext ctx, Object instance)
+ {
+ UIPortlet portlet = (UIPortlet)instance;
+ portlet.setSupportedModes(set);
+ }
+ };
+ }
+ }
+ if ("supportedWindowStates".equals(name))
+ {
+ if (attribute.isLiteral())
+ {
+ String s = attribute.getValue();
+ PropertyEditor editor = PropertyEditorManager.findEditor(String[].class);
+ editor.setAsText(s);
+ String[] values = (String[])editor.getValue();
+ final Set set = Tools.toSet(values);
+ return new Metadata()
+ {
+ public void applyMetadata(FaceletContext ctx, Object instance)
+ {
+ UIPortlet portlet = (UIPortlet)instance;
+ portlet.setSupportedWindowStates(set);
+ }
+ };
+ }
+ }
+ return null;
+ }
+ });
+
+ return mr;
+ }
+}
Modified: trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletRenderEvent.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletRenderEvent.java 2007-03-06 14:51:39 UTC (rev 6551)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletRenderEvent.java 2007-03-06 16:26:19 UTC (rev 6552)
@@ -23,6 +23,8 @@
package org.jboss.portal.core.faces;
import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.Mode;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -38,12 +40,20 @@
/** . */
private final PortletParameters navState;
- public PortletRenderEvent(UIComponent uiComponent, PortletParameters navState)
+ /** . */
+ private Mode mode;
+
+ /** . */
+ private WindowState windowState;
+
+ public PortletRenderEvent(UIComponent uiComponent, PortletParameters navState, Mode mode, WindowState windowState)
{
super(uiComponent);
//
this.navState = navState;
+ this.mode = mode;
+ this.windowState = windowState;
}
public Map getParameterMap()
@@ -51,9 +61,42 @@
return navState;
}
+ public String getMode()
+ {
+ return mode != null ? mode.toString() : null;
+ }
+
+ public void setMode(String mode)
+ {
+ this.mode = mode != null ? Mode.create(mode) : null;
+ }
+
+ public String getWindowState()
+ {
+ return windowState != null ? windowState.toString() : null;
+ }
+
+ public void setWindowState(String windowState)
+ {
+ this.windowState = windowState != null ? WindowState.create(windowState) : null;
+ }
+
void execute(FacesContext faces)
{
UIPortlet uiportlet = (UIPortlet)getComponent();
- uiportlet.setNavState(navState);
+ uiportlet.setInternalNavState(navState);
+
+ //
+ if (windowState != null)
+ {
+
+ uiportlet.setInternalWindowState(windowState);
+ }
+
+ //
+ if (mode != null)
+ {
+ uiportlet.setInternalMode(mode);
+ }
}
}
Modified: trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java 2007-03-06 14:51:39 UTC (rev 6551)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java 2007-03-06 16:26:19 UTC (rev 6552)
@@ -46,6 +46,7 @@
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.Set;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
@@ -58,11 +59,29 @@
private String instanceId;
/** . */
- private MethodBinding portletListener = null;
+ private MethodBinding portletListener;
/** . */
- private PortletParameters navState;
+ private Set supportedWindowStates;
+ /** . */
+ private Set supportedModes;
+
+ /** . */
+ private String initialWindowState;
+
+ /** . */
+ private String initialMode;
+
+ /** . */
+ private PortletParameters internalNavState;
+
+ /** . */
+ private WindowState internalWindowState;
+
+ /** . */
+ private Mode internalMode;
+
public String getInstanceId()
{
if (instanceId != null)
@@ -86,8 +105,148 @@
this.instanceId = instanceId;
}
- void setNavState(PortletParameters navState)
+ public Set getSupportedModes()
{
+ if (supportedModes != null)
+ {
+ return supportedModes;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("supportedModes");
+ if (vb != null)
+ {
+ return (Set)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setSupportedModes(Set supportedModes)
+ {
+ this.supportedModes = supportedModes;
+ }
+
+ public Set getSupportedWindowStates()
+ {
+ if (supportedWindowStates != null)
+ {
+ return supportedWindowStates;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("supportedWindowStates");
+ if (vb != null)
+ {
+ return (Set)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setSupportedWindowStates(Set supportedWindowStates)
+ {
+ this.supportedWindowStates = supportedWindowStates;
+ }
+
+ public String getInitialWindowState()
+ {
+ if (initialWindowState != null)
+ {
+ return initialWindowState;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("initialWindowState");
+ if (vb != null)
+ {
+ return (String)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setInitialWindowState(String initialWindowState)
+ {
+ this.initialWindowState = initialWindowState;
+ }
+
+ public String getInitialMode()
+ {
+ if (initialMode != null)
+ {
+ return initialMode;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("initialMode");
+ if (vb != null)
+ {
+ return (String)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setInitialMode(String initialMode)
+ {
+ this.initialMode = initialMode;
+ }
+
+ WindowState getInternalWindowState()
+ {
+ if (internalWindowState == null)
+ {
+ if (initialWindowState != null)
+ {
+ return WindowState.create(initialWindowState);
+ }
+ else
+ {
+ return WindowState.NORMAL;
+ }
+ }
+ else
+ {
+ return internalWindowState;
+ }
+ }
+
+ void setInternalWindowState(WindowState windowState)
+ {
+ this.internalWindowState = windowState;
+ }
+
+ Mode getInternalMode()
+ {
+ if (internalMode == null)
+ {
+ if (initialMode != null)
+ {
+ return Mode.create(initialMode);
+ }
+ else
+ {
+ return Mode.VIEW;
+ }
+ }
+ else
+ {
+ return internalMode;
+ }
+ }
+
+ void setInternalMode(Mode mode)
+ {
+ this.internalMode = mode;
+ }
+
+ void setInternalNavState(PortletParameters navState)
+ {
ValueBinding vb = getValueBinding("renderParameters");
if (vb != null)
{
@@ -97,11 +256,11 @@
}
else
{
- this.navState = navState;
+ this.internalNavState = navState;
}
}
- PortletParameters getNavState()
+ PortletParameters getInternalNavState()
{
ValueBinding vb = getValueBinding("renderParameters");
if (vb != null)
@@ -111,7 +270,7 @@
}
else
{
- return navState;
+ return internalNavState;
}
}
@@ -161,17 +320,18 @@
public Object saveState(FacesContext faces)
{
String opaqueValue = null;
- if (navState != null)
+ if (internalNavState != null)
{
- opaqueValue = new PortletParametersStateString(navState).getStringValue();
+ opaqueValue = new PortletParametersStateString(internalNavState).getStringValue();
}
//
- Object values[] = new Object[4];
+ Object values[] = new Object[5];
values[0] = super.saveState(faces);
values[1] = instanceId;
values[2] = opaqueValue;
values[3] = saveAttachedState(faces, portletListener);
+ values[4] = supportedModes;
return values;
}
@@ -183,8 +343,9 @@
//
instanceId = (String)values[1];
- navState = serializedNavState != null ? new PortletParametersStateString(serializedNavState).getParameters() : null;
+ internalNavState = serializedNavState != null ? new PortletParametersStateString(serializedNavState).getParameters() : null;
portletListener = (MethodBinding)restoreAttachedState(faces, values[3]);
+ supportedModes = (Set)values[4];
}
public void decode(FacesContext faces)
@@ -215,17 +376,35 @@
// Decode the request
PortletRequestDecoder decoder = new PortletRequestDecoder();
decoder.decode(portletParams, null);
+ Mode mode = decoder.getMode();
+ WindowState windowState = decoder.getWindowState();
//
switch (decoder.getType())
{
case PortletRequestDecoder.RENDER_TYPE:
- PortletRenderEvent prevent = new PortletRenderEvent(this, ((PortletParametersStateString)decoder.getNavigationalState()).getParameters());
+ PortletRenderEvent prevent = new PortletRenderEvent(
+ this,
+ ((PortletParametersStateString)decoder.getNavigationalState()).getParameters(),
+ mode,
+ windowState);
prevent.setPhaseId(PhaseId.INVOKE_APPLICATION);
queueEvent(prevent);
break;
case PortletRequestDecoder.ACTION_TYPE:
- PortletActionEvent paevent = new PortletActionEvent(this, ((PortletParametersStateString)decoder.getInteractionState()).getParameters());
+ if (mode == null)
+ {
+ mode = getInternalMode();
+ }
+ if (windowState == null)
+ {
+ windowState = getInternalWindowState();
+ }
+ PortletActionEvent paevent = new PortletActionEvent(
+ this,
+ ((PortletParametersStateString)decoder.getInteractionState()).getParameters(),
+ mode,
+ windowState);
paevent.setPhaseId(PhaseId.INVOKE_APPLICATION);
queueEvent(paevent);
break;
@@ -257,14 +436,11 @@
//
try
{
- PortletParameters navState = getNavState();
-
- //
PortletInvocationResponse pir = invocation.render(
instance,
- Mode.VIEW,
- WindowState.NORMAL,
- navState);
+ getInternalMode(),
+ getInternalWindowState(),
+ getInternalNavState());
//
if (pir instanceof FragmentResponse)
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml 2007-03-06 14:51:39 UTC (rev 6551)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml 2007-03-06 16:26:19 UTC (rev 6552)
@@ -102,7 +102,11 @@
<div>
<jbp:portlet
instanceId="#{portalobjectmgr.selectedContentEditorInstance}"
- actionListener="#{portalobjectmgr.processEvent}"/>
+ actionListener="#{portalobjectmgr.processEvent}"
+ supportedModes="view"
+ supportedWindowStates="normal"
+ initialMode="view"
+ initialWindowState="normal"/>
</div>
</ui:define>
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portal.taglib.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portal.taglib.xml 2007-03-06 14:51:39 UTC (rev 6551)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portal.taglib.xml 2007-03-06 16:26:19 UTC (rev 6552)
@@ -14,6 +14,7 @@
<component>
<component-type>org.jboss.portal.core.Portlet</component-type>
<renderer-type>default</renderer-type>
+ <handler-class>org.jboss.portal.core.faces.PortletHandler</handler-class>
</component>
</tag>
</facelet-taglib>
\ No newline at end of file
17 years, 4 months
JBoss Portal SVN: r6551 - branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-03-06 09:51:39 -0500 (Tue, 06 Mar 2007)
New Revision: 6551
Modified:
branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins/preferences.xhtml
Log:
Rollback (except in security.xhtml)since it creates a NPE [JBPORTAL-1303]
Modified: branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins/preferences.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins/preferences.xhtml 2007-03-06 14:46:56 UTC (rev 6550)
+++ branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins/preferences.xhtml 2007-03-06 14:51:39 UTC (rev 6551)
@@ -13,8 +13,7 @@
id="data__"
var="row"
value="#{preferences.model}"
- rowClasses="portlet-section-body,portlet-section-alternate"
- preserveDataModel="true">
+ rowClasses="portlet-section-body,portlet-section-alternate">
<h:column>
<f:facet name="header">
<h:outputText value="Key"/>
17 years, 4 months
JBoss Portal SVN: r6550 - trunk/core-admin/src/main/org/jboss/portal/core/faces.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-06 09:46:56 -0500 (Tue, 06 Mar 2007)
New Revision: 6550
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFRenderContext.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java
Log:
better handling of jsf portlet nav state
Modified: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java 2007-03-06 11:22:32 UTC (rev 6549)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java 2007-03-06 14:46:56 UTC (rev 6550)
@@ -162,13 +162,13 @@
Instance instance,
Mode mode,
WindowState windowState,
- PortletParametersStateString navigationalState) throws PortletInvokerException
+ PortletParameters navState) throws PortletInvokerException
{
//
RenderContext renderContext = new JSFRenderContext(
mode,
windowState,
- navigationalState,
+ navState,
new HTTPStreamInfo(MediaType.HTML, "UTF-8"),
this);
Modified: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFRenderContext.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFRenderContext.java 2007-03-06 11:22:32 UTC (rev 6549)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFRenderContext.java 2007-03-06 14:46:56 UTC (rev 6550)
@@ -25,6 +25,8 @@
import org.jboss.portal.portlet.impl.spi.AbstractRenderContext;
import org.jboss.portal.portlet.PortletURL;
import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
@@ -50,11 +52,11 @@
public JSFRenderContext(
Mode mode, WindowState
windowState,
- StateString navigationalState,
+ PortletParameters navState,
HTTPStreamInfo streamInfo,
JSFInvocation invocation)
{
- super(mode, windowState, navigationalState, streamInfo);
+ super(mode, windowState, navState != null ? new PortletParametersStateString(navState) : null, streamInfo);
//
this.invocation = invocation;
Modified: trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java 2007-03-06 11:22:32 UTC (rev 6549)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java 2007-03-06 14:46:56 UTC (rev 6550)
@@ -61,7 +61,7 @@
private MethodBinding portletListener = null;
/** . */
- private Map renderParameters;
+ private PortletParameters navState;
public String getInstanceId()
{
@@ -86,49 +86,33 @@
this.instanceId = instanceId;
}
- public Map getRenderParameters()
+ void setNavState(PortletParameters navState)
{
- if (renderParameters != null)
- {
- return renderParameters;
- }
-
- //
ValueBinding vb = getValueBinding("renderParameters");
if (vb != null)
{
- return (Map)vb.getValue(getFacesContext());
- }
-
- //
- return null;
- }
-
- public void setRenderParameters(Map renderParameters)
- {
- this.renderParameters = renderParameters;
- }
-
- void setNavState(PortletParameters navState)
- {
- Map renderParameters = getRenderParameters();
-
- //
- if (renderParameters != null)
- {
+ Map renderParameters = (Map)vb.getValue(getFacesContext());
renderParameters.clear();
renderParameters.putAll(navState);
}
else
{
- setRenderParameters(navState);
+ this.navState = navState;
}
}
PortletParameters getNavState()
{
- Map renderParameters = getRenderParameters();
- return renderParameters == null ? null : PortletParameters.wrap(renderParameters);
+ ValueBinding vb = getValueBinding("renderParameters");
+ if (vb != null)
+ {
+ Map renderParameters = (Map)vb.getValue(getFacesContext());
+ return PortletParameters.wrap(renderParameters);
+ }
+ else
+ {
+ return navState;
+ }
}
public String getFamily()
@@ -177,9 +161,9 @@
public Object saveState(FacesContext faces)
{
String opaqueValue = null;
- if (renderParameters != null)
+ if (navState != null)
{
- opaqueValue = PortletParametersStateString.create(renderParameters).getStringValue();
+ opaqueValue = new PortletParametersStateString(navState).getStringValue();
}
//
@@ -199,7 +183,7 @@
//
instanceId = (String)values[1];
- renderParameters = serializedNavState != null ? new PortletParametersStateString(serializedNavState).getParameters() : null;
+ navState = serializedNavState != null ? new PortletParametersStateString(serializedNavState).getParameters() : null;
portletListener = (MethodBinding)restoreAttachedState(faces, values[3]);
}
@@ -273,8 +257,7 @@
//
try
{
- Map renderParameters = getRenderParameters();
- PortletParametersStateString navState = renderParameters != null ? PortletParametersStateString.create(renderParameters) : null;
+ PortletParameters navState = getNavState();
//
PortletInvocationResponse pir = invocation.render(
17 years, 4 months
JBoss Portal SVN: r6549 - in trunk: core/src/main/org/jboss/portal/core/model/instance and 11 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-06 06:22:32 -0500 (Tue, 06 Mar 2007)
New Revision: 6549
Added:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java
Modified:
trunk/bridge/src/main/org/jboss/portal/bridge/BridgeInterceptor.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/BeanDecorators.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletActionEvent.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletEvent.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletRenderEvent.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss_portal.tld
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindow.xhtml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portlet-instances.xml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portlet.xml
trunk/core/src/main/org/jboss/portal/core/model/instance/InstanceCommandFactory.java
trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java
trunk/portlet/src/main/org/jboss/portal/portlet/PortletParameters.java
trunk/portlet/src/main/org/jboss/portal/portlet/PortletParametersStateString.java
trunk/portlet/src/main/org/jboss/portal/portlet/impl/PortletRequestDecoder.java
trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java
trunk/portlet/src/main/org/jboss/portal/test/portlet/PortletRequestDecoderTestCase.java
Log:
portlet content editor portlet
Modified: trunk/bridge/src/main/org/jboss/portal/bridge/BridgeInterceptor.java
===================================================================
--- trunk/bridge/src/main/org/jboss/portal/bridge/BridgeInterceptor.java 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/bridge/src/main/org/jboss/portal/bridge/BridgeInterceptor.java 2007-03-06 11:22:32 UTC (rev 6549)
@@ -36,6 +36,7 @@
protected Object invoke(PortletInvocation invocation) throws Exception
{
+ JBossServletContextProvider.BridgeInfo previousInfo = JBossServletContextProvider.get();
try
{
// Set bridge
@@ -48,7 +49,7 @@
finally
{
// Remove bridge
- JBossServletContextProvider.set(null);
+ JBossServletContextProvider.set(previousInfo);
}
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/model/instance/InstanceCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/instance/InstanceCommandFactory.java 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/core/src/main/org/jboss/portal/core/model/instance/InstanceCommandFactory.java 2007-03-06 11:22:32 UTC (rev 6549)
@@ -80,7 +80,7 @@
{
return new InvokePortletInstanceActionCommand(
instanceId,
- decoder.getNavigationalstate(),
+ decoder.getNavigationalState(),
decoder.getInteractionState(),
decoder.getForm());
}
@@ -90,7 +90,7 @@
*/
protected ControllerCommand createPortletRenderCommand(PortletRequestDecoder decoder)
{
- return new InvokePortletInstanceRenderCommand(instanceId, decoder.getNavigationalstate());
+ return new InvokePortletInstanceRenderCommand(instanceId, decoder.getNavigationalState());
}
/**
@@ -98,6 +98,6 @@
*/
protected ControllerCommand createPortletNavCommand(PortletRequestDecoder decoder)
{
- return new InvokePortletInstanceRenderCommand(instanceId, decoder.getNavigationalstate());
+ return new InvokePortletInstanceRenderCommand(instanceId, decoder.getNavigationalState());
}
}
Modified: trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/core/src/main/org/jboss/portal/core/model/portal/PortalObjectCommandFactory.java 2007-03-06 11:22:32 UTC (rev 6549)
@@ -146,10 +146,10 @@
cmd = new InvokePortletWindowRenderCommand(window.getId(), mode, windowState);
break;
case PortletRequestDecoder.ACTION_TYPE:
- cmd = new InvokePortletWindowActionCommand(window.getId(), mode, windowState, decoder.getNavigationalstate(), decoder.getInteractionState(), decoder.getForm());
+ cmd = new InvokePortletWindowActionCommand(window.getId(), mode, windowState, decoder.getNavigationalState(), decoder.getInteractionState(), decoder.getForm());
break;
case PortletRequestDecoder.RENDER_TYPE:
- cmd = new InvokePortletWindowRenderCommand(window.getId(), mode, windowState, decoder.getNavigationalstate());
+ cmd = new InvokePortletWindowRenderCommand(window.getId(), mode, windowState, decoder.getNavigationalState());
break;
}
}
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/BeanDecorators.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/BeanDecorators.java 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/BeanDecorators.java 2007-03-06 11:22:32 UTC (rev 6549)
@@ -24,6 +24,8 @@
import org.jboss.portal.faces.el.decorator.SimpleBeanDecorator;
import org.jboss.portal.faces.el.decorator.AbstractPropertyDecorator;
+import org.jboss.portal.faces.el.decorator.AbstractBeanDecorator;
+import org.jboss.portal.faces.el.decorator.PropertyDecorator;
import org.jboss.portal.faces.el.DelegatingPropertyResolver;
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.identity.IdentityException;
@@ -35,6 +37,8 @@
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.admin.ui.content.ContentEditors;
import javax.faces.context.FacesContext;
import java.util.Set;
@@ -217,6 +221,24 @@
}
});
DelegatingPropertyResolver.registerDecorator(PortalObject.class, portalObjectDecorator);
+
+ //
+ DelegatingPropertyResolver.registerDecorator(ContentEditors.class, new AbstractBeanDecorator()
+ {
+ protected PropertyDecorator getProperty(Object propertyName)
+ {
+ ContentType contentType = ContentType.create((String)propertyName);
+ final String instanceName = ContentEditors.getInstance().getEditor(contentType);
+ return instanceName == null ? null : new AbstractPropertyDecorator(String.class)
+ {
+ public Object getValue(Object bean) throws IllegalArgumentException
+ {
+ return instanceName;
+ }
+ };
+ }
+ });
+
}
}
Modified: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-03-06 11:22:32 UTC (rev 6549)
@@ -51,6 +51,8 @@
import org.jboss.portal.core.model.content.ContentType;
import org.jboss.portal.core.model.content.Content;
import org.jboss.portal.core.admin.ui.actions.WindowComparator;
+import org.jboss.portal.core.admin.ui.content.ContentEditors;
+import org.jboss.portal.core.faces.PortletActionEvent;
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.security.AuthorizationDomainRegistry;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
@@ -111,6 +113,9 @@
/** The uri value for content. */
private String selectedContentURI;
+ /** . */
+ private Map renderParameters;
+
// Runtime state
/** . */
@@ -136,6 +141,20 @@
// Wired services
+ public ContentEditors getContentEditors()
+ {
+ return ContentEditors.getInstance();
+ }
+
+ public String getSelectedContentEditorInstance()
+ {
+ if (selectedContentType != null)
+ {
+ return ContentEditors.getInstance().getEditor(selectedContentType);
+ }
+ return null;
+ }
+
public PortalAuthorizationManagerFactory getPortalAuthorizationManagerFactory()
{
return portalAuthorizationManagerFactory;
@@ -236,6 +255,16 @@
this.selectedPlugin = selectedPlugin;
}
+ public Map getRenderParameters()
+ {
+ return renderParameters;
+ }
+
+ public void setRenderParameters(Map renderParameters)
+ {
+ this.renderParameters = renderParameters;
+ }
+
// Runtime state
public AbstractAuthorizationBean getAuth()
@@ -407,7 +436,8 @@
Content content = window.getContent();
if (content != null)
{
- selectedContentURI = content.getURI();
+ renderParameters = new HashMap();
+ renderParameters.put("uri", new String[]{content.getURI()});
}
break;
}
@@ -567,6 +597,20 @@
selectedProperties = null;
}
+ public void processEvent(ActionEvent event)
+ {
+ if (event instanceof PortletActionEvent)
+ {
+ PortletActionEvent actionEvent = (PortletActionEvent)event;
+ Map actionParams = actionEvent.getParameterMap();
+ if (actionParams.get("meta_action") != null)
+ {
+ String[] uris = (String[])actionParams.get("uri");
+ selectedContentURI = uris[0];
+ }
+ }
+ }
+
public class PortalObjectAuthorizationBean extends AbstractAuthorizationBean
{
Added: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/content/ContentEditors.java 2007-03-06 11:22:32 UTC (rev 6549)
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * 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.core.admin.ui.content;
+
+import org.jboss.portal.common.util.CopyOnWriteRegistry;
+import org.jboss.portal.core.model.content.ContentType;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ContentEditors
+{
+
+ /** . */
+ private static final ContentEditors instance = new ContentEditors();
+
+ /** . */
+ private final CopyOnWriteRegistry editors = new CopyOnWriteRegistry();
+
+ public static ContentEditors getInstance()
+ {
+ return instance;
+ }
+
+ public void registerEditor(ContentType contentType, String instanceName)
+ {
+ editors.register(contentType, instanceName);
+ }
+
+ public void unregisterEditor(ContentType contentType)
+ {
+ editors.unregister(contentType);
+ }
+
+ public String getEditor(ContentType contentType)
+ {
+ return (String)editors.getRegistration(contentType);
+ }
+}
Added: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletContentEditorPortlet.java 2007-03-06 11:22:32 UTC (rev 6549)
@@ -0,0 +1,140 @@
+/******************************************************************************
+ * 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.core.admin.ui.portlet;
+
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.admin.ui.content.ContentEditors;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.info.MetaInfo;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletURL;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletContentEditorPortlet extends GenericPortlet
+{
+
+ /** . */
+ private InstanceContainer instanceContainer;
+
+ public void init() throws PortletException
+ {
+ instanceContainer = (InstanceContainer)getPortletContext().getAttribute("InstanceContainer");
+ ContentEditors.getInstance().registerEditor(ContentType.PORTLET, "PortletContentEditorInstance");
+ }
+
+ public void processAction(ActionRequest req, ActionResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ String uri = req.getParameter("uri");
+ if (uri != null)
+ {
+ resp.setRenderParameter("uri", uri);
+ }
+ }
+
+ public void render(RenderRequest req, RenderResponse resp) throws PortletException, PortletSecurityException, IOException
+ {
+ String selectedURI = req.getParameter("uri");
+
+ //
+ PortletURL actionURL = resp.createActionURL();
+
+ //
+ resp.setContentType("text/html");
+ PrintWriter writer = resp.getWriter();
+
+ // load insances this user has access to.
+ List available_instances = (List)instanceContainer.getDefinitions();
+ Instance selectedInstance = null;
+ writer.print("<form action=\"");
+ writer.print(actionURL);
+ writer.print("\" method=\"post\">\n");
+ writer.println("<select name=\"uri\"size=\"20\">\n");
+ for (int i = 0; i < available_instances.size(); i++)
+ {
+ Instance instance = (Instance)available_instances.get(i);
+
+ //
+ writer.print("<option value=\"");
+ writer.print(instance.getId());
+ writer.print("\"");
+
+ //
+ if (instance.getId().equals(selectedURI))
+ {
+ selectedInstance = instance;
+ writer.print(" selected=\"selected\"");
+ }
+
+ //
+ writer.print(">");
+ writer.print(instance.getId());
+ writer.println("</option>\n");
+ }
+ writer.println("</select>");
+ writer.println("<input name=\"select\" value=\"Select\" type=\"submit\"/>");
+ writer.print("</form>");
+
+ //
+ if (selectedInstance != null)
+ {
+ writer.print("<div class=\"portlet-font\" style=\"float:left\">");
+ writer.print("<div><span class=\"portlet-form-field-label\">Portlet instance:</span>" + selectedURI + "</div>");
+ try
+ {
+ Portlet portlet = selectedInstance.getPortlet();
+ if (portlet != null)
+ {
+ MetaInfo metaInfo = portlet.getInfo().getMeta();
+ writer.print("<div><span class=\"portlet-form-field-label\">Portlet name:</span>" + metaInfo.getMetaValue(MetaInfo.DISPLAY_NAME).getDefaultString() + "</div>");
+ writer.print("<div><span class=\"portlet-form-field-label\">Portlet description:</span>" + metaInfo.getMetaValue(MetaInfo.DESCRIPTION).getDefaultString() + "</div>");
+ writer.print("<div><span class=\"portlet-form-field-label\">Portlet title:</span>" + metaInfo.getMetaValue(MetaInfo.TITLE).getDefaultString() + "</div>");
+ writer.print("<div><span class=\"portlet-form-field-label\">Portlet keywords:</span>" + metaInfo.getMetaValue(MetaInfo.KEYWORDS).getDefaultString() + "</div>");
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ //
+ writer.close();
+ }
+}
Modified: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java 2007-03-06 11:22:32 UTC (rev 6549)
@@ -25,6 +25,8 @@
import org.jboss.portal.portlet.PortletURL;
import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.portlet.invocation.PortletInvocation;
import org.jboss.portal.portlet.invocation.RenderInvocation;
import org.jboss.portal.portlet.invocation.ActionInvocation;
@@ -91,8 +93,9 @@
{
// Get request and response
JBossServletContextProvider.BridgeInfo info = JBossServletContextProvider.get();
- this.clientRequest = info.getInvocation().getDispatchedRequest();
- this.clientResponse = info.getInvocation().getDispatchedResponse();
+ PortletInvocation portletInvocation = info.getInvocation();
+ this.clientRequest = portletInvocation.getDispatchedRequest();
+ this.clientResponse = portletInvocation.getDispatchedResponse();
this.faces = faces;
this.uiportlet = uiportlet;
@@ -159,7 +162,7 @@
Instance instance,
Mode mode,
WindowState windowState,
- StateString navigationalState) throws PortletInvokerException
+ PortletParametersStateString navigationalState) throws PortletInvokerException
{
//
RenderContext renderContext = new JSFRenderContext(
Modified: trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletActionEvent.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletActionEvent.java 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletActionEvent.java 2007-03-06 11:22:32 UTC (rev 6549)
@@ -27,8 +27,8 @@
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.RenderResponse;
import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
@@ -44,9 +44,9 @@
{
/** . */
- private final StateString interactionState;
+ private final PortletParameters interactionState;
- public PortletActionEvent(UIComponent uiComponent, StateString interactionState)
+ public PortletActionEvent(UIComponent uiComponent, PortletParameters interactionState)
{
super(uiComponent);
@@ -56,14 +56,7 @@
public Map getParameterMap()
{
- if (interactionState instanceof PortletParametersStateString)
- {
- PortletParametersStateString ppss = (PortletParametersStateString)interactionState;
- return ppss.getMap();
- }
-
- //
- return null;
+ return interactionState;
}
void execute(FacesContext faces)
@@ -81,11 +74,11 @@
//
try
{
- PortletInvocationResponse pir = invocation.action(instance, Mode.VIEW, WindowState.NORMAL, interactionState);
+ PortletInvocationResponse pir = invocation.action(instance, Mode.VIEW, WindowState.NORMAL, new PortletParametersStateString(interactionState));
if (pir instanceof RenderResponse)
{
RenderResponse render = (RenderResponse)pir;
- uiportlet.navState = render.getNavigationalState();
+ uiportlet.setNavState(((PortletParametersStateString)render.getNavigationalState()).getParameters());
}
}
catch (PortletInvokerException e)
Modified: trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletEvent.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletEvent.java 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletEvent.java 2007-03-06 11:22:32 UTC (rev 6549)
@@ -24,6 +24,7 @@
import javax.faces.event.FacesEvent;
import javax.faces.event.FacesListener;
+import javax.faces.event.ActionEvent;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -31,7 +32,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class PortletEvent extends FacesEvent
+public class PortletEvent extends ActionEvent
{
public PortletEvent(UIComponent uiComponent)
Modified: trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletRenderEvent.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletRenderEvent.java 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletRenderEvent.java 2007-03-06 11:22:32 UTC (rev 6549)
@@ -22,15 +22,7 @@
******************************************************************************/
package org.jboss.portal.core.faces;
-import org.jboss.portal.portlet.StateString;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.PortletParametersStateString;
-import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
-import org.jboss.portal.portlet.invocation.response.RenderResponse;
-import org.jboss.portal.core.model.instance.InstanceContainer;
-import org.jboss.portal.core.model.instance.Instance;
-import org.jboss.portal.Mode;
-import org.jboss.portal.WindowState;
+import org.jboss.portal.portlet.PortletParameters;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -44,31 +36,24 @@
{
/** . */
- private final StateString navigationalState;
+ private final PortletParameters navState;
- public PortletRenderEvent(UIComponent uiComponent, StateString navigationalState)
+ public PortletRenderEvent(UIComponent uiComponent, PortletParameters navState)
{
super(uiComponent);
//
- this.navigationalState = navigationalState;
+ this.navState = navState;
}
public Map getParameterMap()
{
- if (navigationalState instanceof PortletParametersStateString)
- {
- PortletParametersStateString ppss = (PortletParametersStateString)navigationalState;
- return ppss.getMap();
- }
-
- //
- return null;
+ return navState;
}
void execute(FacesContext faces)
{
UIPortlet uiportlet = (UIPortlet)getComponent();
- uiportlet.navState = navigationalState;
+ uiportlet.setNavState(navState);
}
}
Modified: trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java 2007-03-06 11:22:32 UTC (rev 6549)
@@ -27,13 +27,13 @@
import org.jboss.portal.portlet.impl.PortletRequestDecoder;
import org.jboss.portal.portlet.PortletParametersStateString;
import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
-import javax.faces.component.UIComponentBase;
+import javax.faces.component.UICommand;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.ValueBinding;
@@ -51,18 +51,18 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 1.1 $
*/
-public class UIPortlet extends UIComponentBase
+public class UIPortlet extends UICommand
{
- /** The portlet navigational state. */
- StateString navState;
-
/** The portlet instance id. */
private String instanceId;
/** . */
private MethodBinding portletListener = null;
+ /** . */
+ private Map renderParameters;
+
public String getInstanceId()
{
if (instanceId != null)
@@ -86,16 +86,51 @@
this.instanceId = instanceId;
}
- public void setportletListenerListener(MethodBinding portletListener)
+ public Map getRenderParameters()
{
- this.portletListener = portletListener;
+ if (renderParameters != null)
+ {
+ return renderParameters;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("renderParameters");
+ if (vb != null)
+ {
+ return (Map)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
}
- public MethodBinding getPortletListener()
+ public void setRenderParameters(Map renderParameters)
{
- return portletListener;
+ this.renderParameters = renderParameters;
}
+ void setNavState(PortletParameters navState)
+ {
+ Map renderParameters = getRenderParameters();
+
+ //
+ if (renderParameters != null)
+ {
+ renderParameters.clear();
+ renderParameters.putAll(navState);
+ }
+ else
+ {
+ setRenderParameters(navState);
+ }
+ }
+
+ PortletParameters getNavState()
+ {
+ Map renderParameters = getRenderParameters();
+ return renderParameters == null ? null : PortletParameters.wrap(renderParameters);
+ }
+
public String getFamily()
{
return "org.jboss.portal.core.Portlet";
@@ -103,18 +138,17 @@
public void broadcast(FacesEvent event) throws AbortProcessingException
{
- super.broadcast(event);
-
- //
if (event instanceof PortletEvent)
{
FacesContext faces = getFacesContext();
- if (portletListener != null)
+ //
+ MethodBinding listener = getActionListener();
+ if (listener != null)
{
try
{
- portletListener.invoke(faces, new Object[] {event});
+ listener.invoke(faces, new Object[] {event});
}
catch (EvaluationException e)
{
@@ -134,17 +168,26 @@
PortletEvent pevent = (PortletEvent)event;
pevent.execute(faces);
}
+ else
+ {
+ super.broadcast(event);
+ }
}
public Object saveState(FacesContext faces)
{
- String opaqueValue = navState == null ? null : navState.getStringValue();
+ String opaqueValue = null;
+ if (renderParameters != null)
+ {
+ opaqueValue = PortletParametersStateString.create(renderParameters).getStringValue();
+ }
//
- Object values[] = new Object[3];
+ Object values[] = new Object[4];
values[0] = super.saveState(faces);
values[1] = instanceId;
values[2] = opaqueValue;
+ values[3] = saveAttachedState(faces, portletListener);
return values;
}
@@ -156,7 +199,8 @@
//
instanceId = (String)values[1];
- navState = serializedNavState != null ? PortletParametersStateString.create(serializedNavState) : null;
+ renderParameters = serializedNavState != null ? new PortletParametersStateString(serializedNavState).getParameters() : null;
+ portletListener = (MethodBinding)restoreAttachedState(faces, values[3]);
}
public void decode(FacesContext faces)
@@ -192,12 +236,12 @@
switch (decoder.getType())
{
case PortletRequestDecoder.RENDER_TYPE:
- PortletRenderEvent prevent = new PortletRenderEvent(this, decoder.getNavigationalstate());
+ PortletRenderEvent prevent = new PortletRenderEvent(this, ((PortletParametersStateString)decoder.getNavigationalState()).getParameters());
prevent.setPhaseId(PhaseId.INVOKE_APPLICATION);
queueEvent(prevent);
break;
case PortletRequestDecoder.ACTION_TYPE:
- PortletActionEvent paevent = new PortletActionEvent(this, decoder.getInteractionState());
+ PortletActionEvent paevent = new PortletActionEvent(this, ((PortletParametersStateString)decoder.getInteractionState()).getParameters());
paevent.setPhaseId(PhaseId.INVOKE_APPLICATION);
queueEvent(paevent);
break;
@@ -207,36 +251,57 @@
public void encodeBegin(FacesContext faces) throws IOException
{
+ Instance instance = null;
+
+
+ // Resolve instance id
+ String instanceId = getInstanceId();
+
// Get instance
- InstanceContainer instanceContainer = (InstanceContainer)faces.getApplication().getVariableResolver().resolveVariable(faces, "InstanceContainer");
- Instance instance = instanceContainer.getDefinition(instanceId);
+ if (instanceId != null)
+ {
+ InstanceContainer instanceContainer = (InstanceContainer)faces.getApplication().getVariableResolver().resolveVariable(faces, "InstanceContainer");
+ instance = instanceContainer.getDefinition(instanceId);
+ }
//
- JSFInvocation invocation = new JSFInvocation(faces, this);
-
- //
- try
+ if (instance != null)
{
- PortletInvocationResponse pir = invocation.render(
- instance,
- Mode.VIEW,
- WindowState.NORMAL,
- navState);
+ //
+ JSFInvocation invocation = new JSFInvocation(faces, this);
//
- if (pir instanceof FragmentResponse)
+ try
{
- FragmentResponse fragment = (FragmentResponse)pir;
- ResponseWriter writer = faces.getResponseWriter();
- writer.startElement("div", this);
- writer.write(fragment.getContent());
- writer.endElement("div");
- writer.flush();
+ Map renderParameters = getRenderParameters();
+ PortletParametersStateString navState = renderParameters != null ? PortletParametersStateString.create(renderParameters) : null;
+
+ //
+ PortletInvocationResponse pir = invocation.render(
+ instance,
+ Mode.VIEW,
+ WindowState.NORMAL,
+ navState);
+
+ //
+ if (pir instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)pir;
+ ResponseWriter writer = faces.getResponseWriter();
+ writer.startElement("div", this);
+ writer.write(fragment.getContent());
+ writer.endElement("div");
+ writer.flush();
+ }
}
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
}
- catch (PortletInvokerException e)
+ else
{
- e.printStackTrace();
+ System.out.println("Instance not found: " + instanceId);
}
}
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss_portal.tld
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss_portal.tld 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss_portal.tld 2007-03-06 11:22:32 UTC (rev 6549)
@@ -4,8 +4,8 @@
<taglib>
<tlib-version>0.01</tlib-version>
<jsp-version>1.2</jsp-version>
-<short-name>scroller</short-name>
-<uri>http://www.jboss.com/portal</uri>
+<short-name>jbp</short-name>
+<uri>http://www.jboss.org/portal</uri>
<description>This tag library contains the scroller tag.</description>
<tag>
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml 2007-03-06 11:22:32 UTC (rev 6549)
@@ -90,13 +90,9 @@
</tr>
<tr>
<td class="label">
- <span class="portlet-form-field-label label">Portlet instance:</span>
+ <span class="portlet-form-field-label label">Portlet content:</span>
</td>
<td class="widget">
- <ct:content
- contentType="#{portalobjectmgr.selectedContentType}"
- contentURI="#{portalobjectmgr.selectedContentURI}"
- submitFunction="document.layoutForm.submit()"/>
</td>
</tr>
</table>
@@ -104,7 +100,9 @@
</h:form>
<div>
- <jbp:portlet instanceId="URLPortletInstance"/>
+ <jbp:portlet
+ instanceId="#{portalobjectmgr.selectedContentEditorInstance}"
+ actionListener="#{portalobjectmgr.processEvent}"/>
</div>
</ui:define>
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindow.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindow.xhtml 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindow.xhtml 2007-03-06 11:22:32 UTC (rev 6549)
@@ -2,6 +2,7 @@
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:ct="http://www.julien.com"
+ xmlns:jbp="http://www.jboss.org/portal"
xmlns:h="http://java.sun.com/jsf/html">
<ui:composition template="objectTemplate.xhtml">
@@ -9,6 +10,13 @@
<ui:define name="content">
<!-- -->
+ <div>
+ <jbp:portlet
+ instanceId="#{portalobjectmgr.selectedContentEditorInstance}"
+ renderParameters="#{portalobjectmgr.renderParameters}"/>
+ </div>
+
+ <!-- -->
<h:form id="window_form">
<ct:content
contentType="#{portalobjectmgr.selectedContentType}"
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portlet-instances.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portlet-instances.xml 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portlet-instances.xml 2007-03-06 11:22:32 UTC (rev 6549)
@@ -39,4 +39,16 @@
</security-constraint>
</instance>
</deployment>
+ <deployment>
+ <instance>
+ <instance-id>PortletContentEditorInstance</instance-id>
+ <portlet-ref>PortletContentEditorPortlet</portlet-ref>
+ <security-constraint>
+ <policy-permission>
+ <role-name>Admin</role-name>
+ <action-name>view</action-name>
+ </policy-permission>
+ </security-constraint>
+ </instance>
+ </deployment>
</deployments>
\ No newline at end of file
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portlet.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portlet.xml 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portlet.xml 2007-03-06 11:22:32 UTC (rev 6549)
@@ -46,4 +46,18 @@
<keywords>management,admin</keywords>
</portlet-info>
</portlet>
+ <portlet>
+ <description>Portlet Content Editor</description>
+ <portlet-name>PortletContentEditorPortlet</portlet-name>
+ <display-name>Portlet Content Editor</display-name>
+ <portlet-class>org.jboss.portal.core.admin.ui.portlet.PortletContentEditorPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+ </supports>
+ <portlet-info>
+ <title>Portlet Content Portlet</title>
+ <keywords>management,admin</keywords>
+ </portlet-info>
+ </portlet>
</portlet-app>
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/PortletParameters.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/PortletParameters.java 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/PortletParameters.java 2007-03-06 11:22:32 UTC (rev 6549)
@@ -168,4 +168,20 @@
buffer.append(']');
return buffer.toString();
}
+
+ /**
+ * Safely wrap the map as a portlet parameters object. If the map is already a portlet parameter object,
+ * just return that object otherwise return a wrapper around the map.
+ */
+ public static PortletParameters wrap(Map map)
+ {
+ if (map instanceof PortletParameters)
+ {
+ return (PortletParameters)map;
+ }
+ else
+ {
+ return new PortletParameters(map);
+ }
+ }
}
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/PortletParametersStateString.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/PortletParametersStateString.java 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/PortletParametersStateString.java 2007-03-06 11:22:32 UTC (rev 6549)
@@ -73,6 +73,12 @@
}
}
+ public static PortletParametersStateString create(Map parameterMap)
+ {
+ PortletParameters params = PortletParameters.wrap(parameterMap);
+ return new PortletParametersStateString(params);
+ }
+
public PortletParametersStateString(String opaqueValue)
{
if (opaqueValue == null)
@@ -171,12 +177,6 @@
return parameters.getValues(name);
}
- /** Return the a map containing the values. */
- public Map getMap()
- {
- return parameters;
- }
-
/** Clear all the parameters. */
public void clear()
{
@@ -288,7 +288,7 @@
public int hashCode()
{
- return getMap().hashCode();
+ return getParameters().hashCode();
}
public boolean equals(Object o)
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/impl/PortletRequestDecoder.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/impl/PortletRequestDecoder.java 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/impl/PortletRequestDecoder.java 2007-03-06 11:22:32 UTC (rev 6549)
@@ -302,7 +302,7 @@
return windowState;
}
- public StateString getNavigationalstate()
+ public StateString getNavigationalState()
{
return navigationalstate;
}
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/test/PortletController.java 2007-03-06 11:22:32 UTC (rev 6549)
@@ -227,7 +227,7 @@
else
{
//
- invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext().getId(), decoder.getNavigationalstate());
+ invocation.setAttribute(ServerInvocation.NAVIGATIONAL_STATE_SCOPE, portlet.getContext().getId(), decoder.getNavigationalState());
//
Mode mode = decoder.getMode();
Modified: trunk/portlet/src/main/org/jboss/portal/test/portlet/PortletRequestDecoderTestCase.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/test/portlet/PortletRequestDecoderTestCase.java 2007-03-06 11:10:50 UTC (rev 6548)
+++ trunk/portlet/src/main/org/jboss/portal/test/portlet/PortletRequestDecoderTestCase.java 2007-03-06 11:22:32 UTC (rev 6549)
@@ -175,7 +175,7 @@
o.decode(queryParams, null);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.NAV_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -186,7 +186,7 @@
o.decode(queryParams, null);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.NAV_TYPE, o.getType());
assertEquals(Mode.VIEW, o.getMode());
assertNull(o.getWindowState());
@@ -197,7 +197,7 @@
o.decode(queryParams, null);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.NAV_TYPE, o.getType());
assertEquals(Mode.VIEW, o.getMode());
assertNull(o.getWindowState());
@@ -208,7 +208,7 @@
o.decode(queryParams, bodyParams);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.NAV_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -220,7 +220,7 @@
o.decode(queryParams, bodyParams);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.NAV_TYPE, o.getType());
assertEquals(Mode.VIEW, o.getMode());
assertNull(o.getWindowState());
@@ -232,7 +232,7 @@
o.decode(queryParams, null);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.NAV_TYPE, o.getType());
assertNull(o.getMode());
assertEquals(WindowState.NORMAL, o.getWindowState());
@@ -243,7 +243,7 @@
o.decode(queryParams, bodyParams);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.NAV_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -260,7 +260,7 @@
o.decode(queryParams, null);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertEquals(new PortletParametersStateString(), o.getNavigationalstate());
+ assertEquals(new PortletParametersStateString(), o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -272,7 +272,7 @@
o.decode(queryParams, null);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertEquals(new PortletParametersStateString(), o.getNavigationalstate());
+ assertEquals(new PortletParametersStateString(), o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertEquals(Mode.VIEW, o.getMode());
assertNull(o.getWindowState());
@@ -284,7 +284,7 @@
o.decode(queryParams, null);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertEquals(new PortletParametersStateString(), o.getNavigationalstate());
+ assertEquals(new PortletParametersStateString(), o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertNull(o.getMode());
assertEquals(WindowState.NORMAL, o.getWindowState());
@@ -305,7 +305,7 @@
assertNull(o.getForm());
assertNull(o.getInteractionState());
navState.setValue("foo", "bar");
- assertEquals(navState, o.getNavigationalstate());
+ assertEquals(navState, o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -318,7 +318,7 @@
assertNull(o.getForm());
assertNull(o.getInteractionState());
navState.setValue(PortletRequestDecoder.META_PARAMETER, "bar");
- assertEquals(navState, o.getNavigationalstate());
+ assertEquals(navState, o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -332,7 +332,7 @@
assertNull(o.getForm());
assertNull(o.getInteractionState());
navState.setValue(PortletRequestDecoder.WINDOW_STATE_PARAMETER, "bar");
- assertEquals(navState, o.getNavigationalstate());
+ assertEquals(navState, o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertNull(o.getMode());
assertEquals(WindowState.NORMAL, o.getWindowState());
@@ -346,7 +346,7 @@
assertNull(o.getForm());
assertNull(o.getInteractionState());
navState.setValue(PortletRequestDecoder.WINDOW_STATE_PARAMETER, "bar");
- assertEquals(navState, o.getNavigationalstate());
+ assertEquals(navState, o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -360,7 +360,7 @@
assertNull(o.getForm());
assertNull(o.getInteractionState());
navState.setValue(PortletRequestDecoder.MODE_PARAMETER, "bar");
- assertEquals(navState, o.getNavigationalstate());
+ assertEquals(navState, o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertEquals(Mode.VIEW, o.getMode());
assertNull(o.getWindowState());
@@ -374,7 +374,7 @@
assertNull(o.getForm());
assertNull(o.getInteractionState());
navState.setValue(PortletRequestDecoder.MODE_PARAMETER, "bar");
- assertEquals(navState, o.getNavigationalstate());
+ assertEquals(navState, o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -387,7 +387,7 @@
o.decode(queryParams, bodyParams);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertEquals(navState, o.getNavigationalstate());
+ assertEquals(navState, o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -402,7 +402,7 @@
assertNull(o.getForm());
assertNull(o.getInteractionState());
navState.setValues("foo", new String[]{"bar1", "bar2"});
- assertEquals(navState, o.getNavigationalstate());
+ assertEquals(navState, o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -417,7 +417,7 @@
assertNull(o.getForm());
assertNull(o.getInteractionState());
navState.setValue("foo", "bar1");
- assertEquals(navState, o.getNavigationalstate());
+ assertEquals(navState, o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -437,7 +437,7 @@
o.decode(queryParams, null);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -449,7 +449,7 @@
o.decode(queryParams, bodyParams);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertEquals(new OpaqueStateString("navstatevalue"), o.getNavigationalstate());
+ assertEquals(new OpaqueStateString("navstatevalue"), o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -461,7 +461,7 @@
o.decode(queryParams, bodyParams);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -474,7 +474,7 @@
o.decode(queryParams, null);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -486,7 +486,7 @@
o.decode(queryParams, bodyParams);
assertNull(o.getForm());
assertNull(o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.RENDER_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -504,7 +504,7 @@
o.decode(queryParams, null);
assertEquals(new PortletParameters(), o.getForm());
assertEquals(new PortletParametersStateString(), o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -516,7 +516,7 @@
o.decode(queryParams, null);
assertEquals(new PortletParameters(), o.getForm());
assertEquals(new PortletParametersStateString(), o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
assertEquals(Mode.VIEW, o.getMode());
assertNull(o.getWindowState());
@@ -528,7 +528,7 @@
o.decode(queryParams, null);
assertEquals(new PortletParameters(), o.getForm());
assertEquals(new PortletParametersStateString(), o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
assertNull(o.getMode());
assertEquals(WindowState.NORMAL, o.getWindowState());
@@ -550,7 +550,7 @@
assertEquals(form, o.getForm());
intState.setValue("foo", "bar");
assertEquals(intState, o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -565,7 +565,7 @@
assertEquals(form, o.getForm());
intState.setValues("foo", new String[]{"bar1", "bar2"});
assertEquals(intState, o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -580,7 +580,7 @@
form.setValue("foo", "bar");
assertEquals(form, o.getForm());
assertEquals(intState, o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -596,7 +596,7 @@
form.setValues("foo", new String[]{"bar1", "bar2"});
assertEquals(form, o.getForm());
assertEquals(intState, o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -617,7 +617,7 @@
o.decode(queryParams, null);
assertEquals(new PortletParameters(), o.getForm());
assertNull(o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -629,7 +629,7 @@
o.decode(queryParams, null);
assertEquals(new PortletParameters(), o.getForm());
assertNull(o.getInteractionState());
- assertEquals(new OpaqueStateString("navstatevalue"), o.getNavigationalstate());
+ assertEquals(new OpaqueStateString("navstatevalue"), o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -641,7 +641,7 @@
o.decode(queryParams, null);
assertEquals(new PortletParameters(), o.getForm());
assertEquals(new OpaqueStateString("intstatevalue"), o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
@@ -660,7 +660,7 @@
form.setValues("foo3", new String[]{"bar5"});
assertEquals(form, o.getForm());
assertNull(o.getInteractionState());
- assertNull(o.getNavigationalstate());
+ assertNull(o.getNavigationalState());
assertEquals(PortletRequestDecoder.ACTION_TYPE, o.getType());
assertNull(o.getMode());
assertNull(o.getWindowState());
17 years, 4 months
JBoss Portal SVN: r6548 - branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins.
by portal-commits@lists.jboss.org
Author: thomas.heute(a)jboss.com
Date: 2007-03-06 06:10:50 -0500 (Tue, 06 Mar 2007)
New Revision: 6548
Modified:
branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins/preferences.xhtml
branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins/properties.xhtml
branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins/security.xhtml
Log:
Datamodel must be kept for a request lifetime. [JBPORTAL-1303]
Modified: branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins/preferences.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins/preferences.xhtml 2007-03-06 06:50:49 UTC (rev 6547)
+++ branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins/preferences.xhtml 2007-03-06 11:10:50 UTC (rev 6548)
@@ -13,7 +13,8 @@
id="data__"
var="row"
value="#{preferences.model}"
- rowClasses="portlet-section-body,portlet-section-alternate">
+ rowClasses="portlet-section-body,portlet-section-alternate"
+ preserveDataModel="true">
<h:column>
<f:facet name="header">
<h:outputText value="Key"/>
Modified: branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins/properties.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins/properties.xhtml 2007-03-06 06:50:49 UTC (rev 6547)
+++ branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins/properties.xhtml 2007-03-06 11:10:50 UTC (rev 6548)
@@ -39,7 +39,8 @@
var="p"
value="#{portalobjectmgr.selectedProperties}"
binding="#{propertyAction.propertyDataTable}"
- rowClasses="portlet-section-body,portlet-section-alternate">
+ rowClasses="portlet-section-body,portlet-section-alternate"
+ preserveDataModel="true">
<h:column>
<f:facet id="the_id_that_fixes_the_bug_1" name="header">
<h:outputText id="the_id_that_fixes_the_bug_2" value="Operations"/>
Modified: branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins/security.xhtml
===================================================================
--- branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins/security.xhtml 2007-03-06 06:50:49 UTC (rev 6547)
+++ branches/JBoss_Portal_Branch_2_4/core/src/resources/portal-core-war/WEB-INF/jsp/management/plugins/security.xhtml 2007-03-06 11:10:50 UTC (rev 6548)
@@ -12,7 +12,8 @@
<t:dataTable
id="dataconstraints"
var="role"
- value="#{auth.roles}">
+ value="#{auth.roles}"
+ preserveDataModel="true">
<h:column
id="role_column">
<f:facet name="header">
17 years, 4 months
JBoss Portal SVN: r6547 - trunk/wsrp/src/main/org/jboss/portal/wsrp/services.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2007-03-06 01:50:49 -0500 (Tue, 06 Mar 2007)
New Revision: 6547
Modified:
trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
Log:
- JBPORTAL-1279: Open the URL in a different thread and wait for it to finish for 1 second or declare failure.
Modified: trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java
===================================================================
--- trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2007-03-05 21:50:53 UTC (rev 6546)
+++ trunk/wsrp/src/main/org/jboss/portal/wsrp/services/RemoteSOAPInvokerServiceFactory.java 2007-03-06 06:50:49 UTC (rev 6547)
@@ -24,6 +24,7 @@
package org.jboss.portal.wsrp.services;
import org.jboss.logging.Logger;
+import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.common.util.Tools;
import org.xml.sax.InputSource;
@@ -92,6 +93,7 @@
}
catch (Exception e)
{
+ log.info("Couldn't access WSDL information. Service won't be available", e);
available = false;
}
}
@@ -171,9 +173,86 @@
log.info("Retrieving WSDL from " + url);
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
javax.wsdl.xml.WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
- return wsdlReader.readWSDL(new WSDLLocatorImpl(url));
+ try
+ {
+ return wsdlReader.readWSDL(new WSDLLocatorImpl(url));
+ }
+ catch (RuntimeException e)
+ {
+ throw new WSDLException(WSDLException.PARSER_ERROR, "Error while reading WSDL", e);
+ }
}
+
+ static class URLThread extends Thread
+ {
+ volatile private URL url;
+ private InputSource inputSource;
+ /** Exception in the event a connection error occurs */
+ private IOException exception = null;
+
+ // Connect to the specified host and port number
+ public URLThread(URL wsdlFile)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(wsdlFile, "WSDL URL");
+
+ this.url = wsdlFile;
+ }
+
+ public void run()
+ {
+ try
+ {
+ InputStream is = Tools.safeBufferedWrapper(url.openStream());
+ if (is == null)
+ {
+ throw new IllegalArgumentException("Cannot obtain wsdl from [" + url + "]");
+ }
+
+ inputSource = new InputSource(is);
+ }
+ catch (IOException e)
+ {
+ exception = e;
+ }
+ }
+
+ public boolean isConnected()
+ {
+ if (inputSource == null)
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ public boolean isError()
+ {
+ if (exception == null)
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+
+ public InputSource getInputSource()
+ {
+ return inputSource;
+ }
+
+ public IOException getException()
+ {
+ return exception;
+ }
+ }
+
/** A WSDLLocator that can handle wsdl imports */
public static class WSDLLocatorImpl implements WSDLLocator
{
@@ -183,10 +262,7 @@
public WSDLLocatorImpl(URL wsdlFile)
{
- if (wsdlFile == null)
- {
- throw new IllegalArgumentException("WSDL file argument cannot be null");
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(wsdlFile, "WSDL URL");
this.wsdlURL = wsdlFile;
}
@@ -195,7 +271,44 @@
{
log.info("getBaseInputSource [wsdlUrl=" + wsdlURL + "]");
- // use 1 second time outs and remember previous values
+ URLThread thread = new URLThread(wsdlURL);
+ thread.start();
+
+ // Wait for the thread to finish but don't wait longer than a
+ // specified time
+ long delayMillis = 1000;
+ try
+ {
+ thread.join(delayMillis);
+
+ if (thread.isAlive())
+ {
+ // Timeout occurred; thread has not finished
+ // todo: do we need clean up here?
+ throw new RuntimeException("Couldn't connect to " + wsdlURL + " within " + delayMillis / 1000
+ + " seconds. Check your connection parameters or the URL.");
+ }
+ else
+ {
+ // Finished
+ if (thread.isConnected() && !thread.isError())
+ {
+ return thread.getInputSource();
+ }
+ else
+ {
+ throw new RuntimeException("An error occured while parsing the WSDL file at " + wsdlURL,
+ thread.getException());
+ }
+ }
+ }
+ catch (InterruptedException e)
+ {
+ // Thread was interrupted
+ throw new RuntimeException("Parsing thread was interrupted!", e);
+ }
+
+ /*// use 1 second time outs and remember previous values
String connectTimeOut = System.setProperty("sun.net.client.defaultConnectTimeout", "1000");
String readTimeOut = System.setProperty("sun.net.client.defaultReadTimeout", "1000");
@@ -225,8 +338,7 @@
{
System.setProperty("sun.net.client.defaultReadTimeout", readTimeOut);
}
- }
-
+ }*/
}
public String getBaseURI()
17 years, 4 months
JBoss Portal SVN: r6546 - in trunk: build/ide/intellij/idea60/modules/core-admin and 7 other directories.
by portal-commits@lists.jboss.org
Author: julien(a)jboss.com
Date: 2007-03-05 16:50:53 -0500 (Mon, 05 Mar 2007)
New Revision: 6546
Added:
trunk/core-admin/src/main/org/jboss/portal/core/faces/
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFActionContext.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFPortalContext.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFRenderContext.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFSecurityContext.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFUserContext.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFWindowContext.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletActionEvent.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletEvent.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletListener.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletRenderEvent.java
trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java
Modified:
trunk/bridge/src/main/org/jboss/portal/bridge/JBossServletContextProvider.java
trunk/build/ide/intellij/idea60/modules/core-admin/core-admin.iml
trunk/core-admin/build.xml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portal.taglib.xml
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/URLPortlet.java
trunk/portlet/src/main/org/jboss/portal/portlet/PortletParametersStateString.java
Log:
added JSF component that show portlets
Modified: trunk/bridge/src/main/org/jboss/portal/bridge/JBossServletContextProvider.java
===================================================================
--- trunk/bridge/src/main/org/jboss/portal/bridge/JBossServletContextProvider.java 2007-03-05 20:20:08 UTC (rev 6545)
+++ trunk/bridge/src/main/org/jboss/portal/bridge/JBossServletContextProvider.java 2007-03-05 21:50:53 UTC (rev 6546)
@@ -44,6 +44,7 @@
public class JBossServletContextProvider implements ServletContextProvider
{
+ /** . */
private static final ThreadLocal local = new ThreadLocal();
static void set(BridgeInfo info)
@@ -51,7 +52,7 @@
local.set(info);
}
- static BridgeInfo get()
+ public static BridgeInfo get()
{
return (BridgeInfo)local.get();
}
Modified: trunk/build/ide/intellij/idea60/modules/core-admin/core-admin.iml
===================================================================
--- trunk/build/ide/intellij/idea60/modules/core-admin/core-admin.iml 2007-03-05 20:20:08 UTC (rev 6545)
+++ trunk/build/ide/intellij/idea60/modules/core-admin/core-admin.iml 2007-03-05 21:50:53 UTC (rev 6546)
@@ -110,6 +110,8 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="module" module-name="bridge" />
+ <orderEntry type="module" module-name="server" />
<orderEntryProperties />
</component>
<component name="VcsManagerConfiguration">
Modified: trunk/core-admin/build.xml
===================================================================
--- trunk/core-admin/build.xml 2007-03-05 20:20:08 UTC (rev 6545)
+++ trunk/core-admin/build.xml 2007-03-05 21:50:53 UTC (rev 6546)
@@ -105,6 +105,7 @@
<path refid="jboss.portal-format.classpath"/>
<path refid="jboss.portal-common.classpath"/>
<path refid="jboss.portal-faces.classpath"/>
+ <path refid="jboss.portal-bridge.classpath"/>
<path refid="jboss.portal-server.classpath"/>
<path refid="jboss.portal-registration.classpath"/>
<path refid="jboss.portal-portlet.classpath"/>
Added: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFActionContext.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFActionContext.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFActionContext.java 2007-03-05 21:50:53 UTC (rev 6546)
@@ -0,0 +1,83 @@
+/******************************************************************************
+ * 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.core.faces;
+
+import org.jboss.portal.portlet.impl.spi.AbstractActionContext;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.invocation.EmptyAttributeResolver;
+import org.jboss.portal.server.util.HTTPStreamInfo;
+import org.jboss.portal.server.impl.RequestAttributeResolver;
+import org.jboss.portal.server.impl.PrincipalAttributeResolver;
+import org.jboss.portal.server.impl.MapAttributeResolver;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFActionContext extends AbstractActionContext
+{
+
+ /** . */
+ private final JSFInvocation invocation;
+
+ public JSFActionContext(
+ Mode mode, WindowState
+ windowState,
+ StateString interactionState,
+ HTTPStreamInfo streamInfo,
+ JSFInvocation invocation)
+ {
+ super(mode, windowState, null, streamInfo, interactionState, null);
+
+ //
+ this.invocation = invocation;
+
+ //
+ addResolver(PortletInvocation.REQUEST_SCOPE, new RequestAttributeResolver(invocation.clientRequest));
+ addResolver(PortletInvocation.PRINCIPAL_SCOPE, new PrincipalAttributeResolver(invocation.clientRequest));
+ addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, EmptyAttributeResolver.getInstance());
+ addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new MapAttributeResolver());
+ }
+
+ public HttpServletRequest getClientRequest() throws IllegalStateException
+ {
+ return invocation.clientRequest;
+ }
+
+ public HttpServletResponse getClientResponse() throws IllegalStateException
+ {
+ return invocation.clientResponse;
+ }
+
+ public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ {
+ return invocation.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
+ }
+}
Added: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java 2007-03-05 21:50:53 UTC (rev 6546)
@@ -0,0 +1,193 @@
+/******************************************************************************
+ * 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.core.faces;
+
+import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.portlet.invocation.RenderInvocation;
+import org.jboss.portal.portlet.invocation.ActionInvocation;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.spi.PortalContext;
+import org.jboss.portal.portlet.spi.RequestContext;
+import org.jboss.portal.portlet.spi.SecurityContext;
+import org.jboss.portal.portlet.spi.UserContext;
+import org.jboss.portal.portlet.spi.WindowContext;
+import org.jboss.portal.portlet.spi.RenderContext;
+import org.jboss.portal.portlet.spi.ActionContext;
+import org.jboss.portal.portlet.impl.PortletRequestEncoder;
+import org.jboss.portal.portlet.impl.spi.AbstractRequestContext;
+import org.jboss.portal.common.text.FastURLEncoder;
+import org.jboss.portal.common.MediaType;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.bridge.JBossServletContextProvider;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.server.util.HTTPStreamInfo;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.faces.context.FacesContext;
+import javax.faces.application.ViewHandler;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFInvocation
+{
+
+ /** . */
+ final HttpServletRequest clientRequest;
+
+ /** . */
+ final HttpServletResponse clientResponse;
+
+ /** . */
+ final FacesContext faces;
+
+ /** . */
+ final UIPortlet uiportlet;
+
+ /** . */
+ final PortalContext portalContext;
+
+ /** . */
+ final RequestContext requestContext;
+
+ /** . */
+ final SecurityContext securityContext;
+
+ /** . */
+ final UserContext userContext;
+
+ /** . */
+ final WindowContext windowContext;
+
+ public JSFInvocation(FacesContext faces, UIPortlet uiportlet)
+ {
+ // Get request and response
+ JBossServletContextProvider.BridgeInfo info = JBossServletContextProvider.get();
+ this.clientRequest = info.getInvocation().getDispatchedRequest();
+ this.clientResponse = info.getInvocation().getDispatchedResponse();
+ this.faces = faces;
+ this.uiportlet = uiportlet;
+
+ //
+ this.portalContext = new JSFPortalContext(faces);
+ this.requestContext = new AbstractRequestContext(clientRequest, clientResponse);
+ this.securityContext = new JSFSecurityContext(faces);
+ this.userContext = new JSFUserContext(faces);
+ this.windowContext = new JSFWindowContext(faces);
+ }
+
+ String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ {
+ ViewHandler vh = faces.getApplication().getViewHandler();
+ String viewId = faces.getViewRoot().getViewId();
+ String clientId = uiportlet.getClientId(faces);
+ StringBuffer url = new StringBuffer(vh.getActionURL(faces, viewId));
+
+ //
+ url.append("&").append(clientId).append("=jbp");
+
+ //
+ PortletRequestEncoder encoder = new PortletRequestEncoder();
+ encoder.encode(portletURL);
+ for (Iterator i = encoder.getQueryParameters().entrySet().iterator();i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String name = FastURLEncoder.DEFAULT_ENCODER.encode((String)entry.getKey());
+ String[] values = (String[])entry.getValue();
+ for (int j = 0;j < values.length;j++)
+ {
+ String value = values[j];
+ url.append("&").append(name).append('=');
+ FastURLEncoder.DEFAULT_ENCODER.encode(value, url);
+ }
+ }
+
+ //
+ return url.toString();
+ }
+
+ public PortletInvocationResponse action(
+ Instance instance,
+ Mode mode,
+ WindowState windowState,
+ StateString interactionState) throws PortletInvokerException
+ {
+ //
+ ActionContext actionContext = new JSFActionContext(
+ mode,
+ windowState,
+ interactionState,
+ new HTTPStreamInfo(MediaType.HTML, "UTF-8"),
+ this);
+
+ //
+ PortletInvocation action = new ActionInvocation(actionContext);
+
+ //
+ return invoke(instance, action);
+ }
+
+ public PortletInvocationResponse render(
+ Instance instance,
+ Mode mode,
+ WindowState windowState,
+ StateString navigationalState) throws PortletInvokerException
+ {
+ //
+ RenderContext renderContext = new JSFRenderContext(
+ mode,
+ windowState,
+ navigationalState,
+ new HTTPStreamInfo(MediaType.HTML, "UTF-8"),
+ this);
+
+ //
+ PortletInvocation render = new RenderInvocation(renderContext);
+
+ //
+ return invoke(instance, render);
+ }
+
+ private PortletInvocationResponse invoke(
+ Instance instance,
+ PortletInvocation invocation) throws PortletInvokerException
+ {
+ //
+ invocation.setPortalContext(portalContext);
+ invocation.setSecurityContext(securityContext);
+ invocation.setUserContext(userContext);
+ invocation.setRequestContext(requestContext);
+ invocation.setWindowContext(windowContext);
+
+ //
+ return instance.invoke(invocation);
+ }
+}
Added: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFPortalContext.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFPortalContext.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFPortalContext.java 2007-03-05 21:50:53 UTC (rev 6546)
@@ -0,0 +1,70 @@
+/******************************************************************************
+ * 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.core.faces;
+
+import org.jboss.portal.common.util.Tools;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.portlet.spi.PortalContext;
+
+import javax.faces.context.FacesContext;
+import java.util.Set;
+import java.util.Map;
+import java.util.Collections;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFPortalContext implements PortalContext
+{
+
+ /** . */
+ private static final Set modes = Collections.unmodifiableSet(Tools.toSet(new Mode[]{Mode.VIEW,Mode.EDIT,Mode.HELP}));
+
+ /** . */
+ private static final Set windowStates = Collections.unmodifiableSet(Tools.toSet(new WindowState[]{WindowState.NORMAL,WindowState.MINIMIZED,WindowState.MAXIMIZED}));
+
+ /** . */
+ private final FacesContext faces;
+
+ public JSFPortalContext(FacesContext faces)
+ {
+ this.faces = faces;
+ }
+
+ public Set getWindowStates()
+ {
+ return windowStates;
+ }
+
+ public Set getModes()
+ {
+ return modes;
+ }
+
+ public Map getProperties()
+ {
+ return Collections.EMPTY_MAP;
+ }
+}
Added: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFRenderContext.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFRenderContext.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFRenderContext.java 2007-03-05 21:50:53 UTC (rev 6546)
@@ -0,0 +1,83 @@
+/******************************************************************************
+ * 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.core.faces;
+
+import org.jboss.portal.portlet.impl.spi.AbstractRenderContext;
+import org.jboss.portal.portlet.PortletURL;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.common.invocation.EmptyAttributeResolver;
+import org.jboss.portal.server.util.HTTPStreamInfo;
+import org.jboss.portal.server.impl.MapAttributeResolver;
+import org.jboss.portal.server.impl.PrincipalAttributeResolver;
+import org.jboss.portal.server.impl.RequestAttributeResolver;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFRenderContext extends AbstractRenderContext
+{
+
+ /** . */
+ private final JSFInvocation invocation;
+
+ public JSFRenderContext(
+ Mode mode, WindowState
+ windowState,
+ StateString navigationalState,
+ HTTPStreamInfo streamInfo,
+ JSFInvocation invocation)
+ {
+ super(mode, windowState, navigationalState, streamInfo);
+
+ //
+ this.invocation = invocation;
+
+ //
+ addResolver(PortletInvocation.REQUEST_SCOPE, new RequestAttributeResolver(invocation.clientRequest));
+ addResolver(PortletInvocation.PRINCIPAL_SCOPE, new PrincipalAttributeResolver(invocation.clientRequest));
+ addResolver(PortletInvocation.REQUEST_PROPERTIES_SCOPE, EmptyAttributeResolver.getInstance());
+ addResolver(PortletInvocation.RESPONSE_PROPERTIES_SCOPE, new MapAttributeResolver());
+ }
+
+ public HttpServletRequest getClientRequest() throws IllegalStateException
+ {
+ return invocation.clientRequest;
+ }
+
+ public HttpServletResponse getClientResponse() throws IllegalStateException
+ {
+ return invocation.clientResponse;
+ }
+
+ public String renderURL(PortletURL portletURL, Boolean wantSecure, Boolean wantAuthenticated, boolean relative)
+ {
+ return invocation.renderURL(portletURL, wantSecure, wantAuthenticated, relative);
+ }
+}
Added: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFSecurityContext.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFSecurityContext.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFSecurityContext.java 2007-03-05 21:50:53 UTC (rev 6546)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * 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.core.faces;
+
+import org.jboss.portal.portlet.spi.SecurityContext;
+
+import javax.faces.context.FacesContext;
+import java.security.Principal;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFSecurityContext implements SecurityContext
+{
+
+ /** . */
+ private final FacesContext faces;
+
+ public JSFSecurityContext(FacesContext faces)
+ {
+ this.faces = faces;
+ }
+
+ public boolean isSecure()
+ {
+ return false;
+ }
+
+ public boolean isAuthenticated()
+ {
+ return faces.getExternalContext().getRemoteUser() != null;
+ }
+
+ public String getAuthType()
+ {
+ return faces.getExternalContext().getAuthType();
+ }
+
+ public String getRemoteUser()
+ {
+ return faces.getExternalContext().getRemoteUser();
+ }
+
+ public Principal getUserPrincipal()
+ {
+ return faces.getExternalContext().getUserPrincipal();
+ }
+
+ public boolean isUserInRole(String roleName)
+ {
+ return faces.getExternalContext().isUserInRole(roleName);
+ }
+}
Added: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFUserContext.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFUserContext.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFUserContext.java 2007-03-05 21:50:53 UTC (rev 6546)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * 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.core.faces;
+
+import org.jboss.portal.portlet.spi.UserContext;
+import org.jboss.portal.common.util.Tools;
+
+import javax.faces.context.FacesContext;
+import java.util.Map;
+import java.util.Locale;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFUserContext implements UserContext
+{
+
+ /** . */
+ private final FacesContext faces;
+
+ public JSFUserContext(FacesContext faces)
+ {
+ this.faces = faces;
+ }
+
+ public String getId()
+ {
+ return null;
+ }
+
+ public Map getInformations()
+ {
+ return null;
+ }
+
+ public Locale getLocale()
+ {
+ return faces.getExternalContext().getRequestLocale();
+ }
+
+ public List getLocales()
+ {
+ return Tools.toList(faces.getExternalContext().getRequestLocales());
+ }
+}
Added: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFWindowContext.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFWindowContext.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFWindowContext.java 2007-03-05 21:50:53 UTC (rev 6546)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * 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.core.faces;
+
+import org.jboss.portal.portlet.spi.WindowContext;
+import org.jboss.portal.common.util.UUIDGenerator;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFWindowContext implements WindowContext
+{
+
+ /** . */
+ private static final UUIDGenerator generator = new UUIDGenerator();
+
+ /** . */
+ private final FacesContext faces;
+
+ /** . */
+ private String id;
+
+ public JSFWindowContext(FacesContext faces)
+ {
+ this.faces = faces;
+ this.id = generator.generateKey();
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+}
Added: trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletActionEvent.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletActionEvent.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletActionEvent.java 2007-03-05 21:50:53 UTC (rev 6546)
@@ -0,0 +1,96 @@
+/******************************************************************************
+ * 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.core.faces;
+
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.RenderResponse;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletActionEvent extends PortletEvent
+{
+
+ /** . */
+ private final StateString interactionState;
+
+ public PortletActionEvent(UIComponent uiComponent, StateString interactionState)
+ {
+ super(uiComponent);
+
+ //
+ this.interactionState = interactionState;
+ }
+
+ public Map getParameterMap()
+ {
+ if (interactionState instanceof PortletParametersStateString)
+ {
+ PortletParametersStateString ppss = (PortletParametersStateString)interactionState;
+ return ppss.getMap();
+ }
+
+ //
+ return null;
+ }
+
+ void execute(FacesContext faces)
+ {
+ UIPortlet uiportlet = (UIPortlet)getComponent();
+
+ // Get instance
+ String instanceId = uiportlet.getInstanceId();
+ InstanceContainer instanceContainer = (InstanceContainer)faces.getApplication().getVariableResolver().resolveVariable(faces, "InstanceContainer");
+ Instance instance = instanceContainer.getDefinition(instanceId);
+
+ //
+ JSFInvocation invocation = new JSFInvocation(faces, uiportlet);
+
+ //
+ try
+ {
+ PortletInvocationResponse pir = invocation.action(instance, Mode.VIEW, WindowState.NORMAL, interactionState);
+ if (pir instanceof RenderResponse)
+ {
+ RenderResponse render = (RenderResponse)pir;
+ uiportlet.navState = render.getNavigationalState();
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
Added: trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletEvent.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletEvent.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletEvent.java 2007-03-05 21:50:53 UTC (rev 6546)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * 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.core.faces;
+
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletEvent extends FacesEvent
+{
+
+ public PortletEvent(UIComponent uiComponent)
+ {
+ super(uiComponent);
+ }
+
+ public boolean isAppropriateListener(FacesListener listener)
+ {
+ return listener instanceof PortletListener;
+ }
+
+ public void processListener(FacesListener listener)
+ {
+ ((PortletListener)listener).processEvent(this);
+ }
+
+ void execute(FacesContext faces)
+ {
+ }
+}
Added: trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletListener.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletListener.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletListener.java 2007-03-05 21:50:53 UTC (rev 6546)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * 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.core.faces;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public interface PortletListener extends FacesListener
+{
+ void processEvent(PortletEvent event);
+}
Added: trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletRenderEvent.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletRenderEvent.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletRenderEvent.java 2007-03-05 21:50:53 UTC (rev 6546)
@@ -0,0 +1,74 @@
+/******************************************************************************
+ * 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.core.faces;
+
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.RenderResponse;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletRenderEvent extends PortletEvent
+{
+
+ /** . */
+ private final StateString navigationalState;
+
+ public PortletRenderEvent(UIComponent uiComponent, StateString navigationalState)
+ {
+ super(uiComponent);
+
+ //
+ this.navigationalState = navigationalState;
+ }
+
+ public Map getParameterMap()
+ {
+ if (navigationalState instanceof PortletParametersStateString)
+ {
+ PortletParametersStateString ppss = (PortletParametersStateString)navigationalState;
+ return ppss.getMap();
+ }
+
+ //
+ return null;
+ }
+
+ void execute(FacesContext faces)
+ {
+ UIPortlet uiportlet = (UIPortlet)getComponent();
+ uiportlet.navState = navigationalState;
+ }
+}
Added: trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java (rev 0)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java 2007-03-05 21:50:53 UTC (rev 6546)
@@ -0,0 +1,256 @@
+/******************************************************************************
+ * 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.core.faces;
+
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.portlet.impl.PortletRequestDecoder;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.StateString;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.response.FragmentResponse;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.el.ValueBinding;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.EvaluationException;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.PhaseId;
+import java.io.IOException;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class UIPortlet extends UIComponentBase
+{
+
+ /** The portlet navigational state. */
+ StateString navState;
+
+ /** The portlet instance id. */
+ private String instanceId;
+
+ /** . */
+ private MethodBinding portletListener = null;
+
+ public String getInstanceId()
+ {
+ if (instanceId != null)
+ {
+ return instanceId;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("instanceId");
+ if (vb != null)
+ {
+ return (String)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setInstanceId(String instanceId)
+ {
+ this.instanceId = instanceId;
+ }
+
+ public void setportletListenerListener(MethodBinding portletListener)
+ {
+ this.portletListener = portletListener;
+ }
+
+ public MethodBinding getPortletListener()
+ {
+ return portletListener;
+ }
+
+ public String getFamily()
+ {
+ return "org.jboss.portal.core.Portlet";
+ }
+
+ public void broadcast(FacesEvent event) throws AbortProcessingException
+ {
+ super.broadcast(event);
+
+ //
+ if (event instanceof PortletEvent)
+ {
+ FacesContext faces = getFacesContext();
+
+ if (portletListener != null)
+ {
+ try
+ {
+ portletListener.invoke(faces, new Object[] {event});
+ }
+ catch (EvaluationException e)
+ {
+ Throwable cause = e.getCause();
+ if (cause != null && cause instanceof AbortProcessingException)
+ {
+ throw (AbortProcessingException)cause;
+ }
+ else
+ {
+ throw e;
+ }
+ }
+ }
+
+ //
+ PortletEvent pevent = (PortletEvent)event;
+ pevent.execute(faces);
+ }
+ }
+
+ public Object saveState(FacesContext faces)
+ {
+ String opaqueValue = navState == null ? null : navState.getStringValue();
+
+ //
+ Object values[] = new Object[3];
+ values[0] = super.saveState(faces);
+ values[1] = instanceId;
+ values[2] = opaqueValue;
+ return values;
+ }
+
+ public void restoreState(FacesContext faces, Object state)
+ {
+ Object values[] = (Object[])state;
+ super.restoreState(faces, values[0]);
+ String serializedNavState = (String)values[2];
+
+ //
+ instanceId = (String)values[1];
+ navState = serializedNavState != null ? PortletParametersStateString.create(serializedNavState) : null;
+ }
+
+ public void decode(FacesContext faces)
+ {
+ String clientId = getClientId(faces);
+ String clientIdValue = (String)faces.getExternalContext().getRequestParameterMap().get(clientId);
+
+ // We have been targetted
+ if ("jbp".equals(clientIdValue))
+ {
+ Map jsfParams = faces.getExternalContext().getRequestParameterValuesMap();
+ Map portletParams = new HashMap();
+ for (Iterator i = jsfParams.entrySet().iterator();i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ String name = (String)entry.getKey();
+ if (clientId.equals(name))
+ {
+ // Skip the client id
+ }
+ else
+ {
+ String[] values = (String[])((String[])entry.getValue()).clone();
+ portletParams.put(name, values);
+ }
+ }
+
+ // Decode the request
+ PortletRequestDecoder decoder = new PortletRequestDecoder();
+ decoder.decode(portletParams, null);
+
+ //
+ switch (decoder.getType())
+ {
+ case PortletRequestDecoder.RENDER_TYPE:
+ PortletRenderEvent prevent = new PortletRenderEvent(this, decoder.getNavigationalstate());
+ prevent.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ queueEvent(prevent);
+ break;
+ case PortletRequestDecoder.ACTION_TYPE:
+ PortletActionEvent paevent = new PortletActionEvent(this, decoder.getInteractionState());
+ paevent.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ queueEvent(paevent);
+ break;
+ }
+ }
+ }
+
+ public void encodeBegin(FacesContext faces) throws IOException
+ {
+ // Get instance
+ InstanceContainer instanceContainer = (InstanceContainer)faces.getApplication().getVariableResolver().resolveVariable(faces, "InstanceContainer");
+ Instance instance = instanceContainer.getDefinition(instanceId);
+
+ //
+ JSFInvocation invocation = new JSFInvocation(faces, this);
+
+ //
+ try
+ {
+ PortletInvocationResponse pir = invocation.render(
+ instance,
+ Mode.VIEW,
+ WindowState.NORMAL,
+ navState);
+
+ //
+ if (pir instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)pir;
+ ResponseWriter writer = faces.getResponseWriter();
+ writer.startElement("div", this);
+ writer.write(fragment.getContent());
+ writer.endElement("div");
+ writer.flush();
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void encodeChildren(FacesContext facesContext) throws IOException
+ {
+ }
+
+ public void encodeEnd(FacesContext facesContext) throws IOException
+ {
+ }
+
+ public String getRendererType()
+ {
+ // Returns null as we handle rendering ourselves
+ return null;
+ }
+}
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2007-03-05 20:20:08 UTC (rev 6545)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2007-03-05 21:50:53 UTC (rev 6546)
@@ -252,6 +252,11 @@
<component-type>com.jboss.portal.Scroller</component-type>
<component-class>org.jboss.portal.faces.scroller.UIScroller</component-class>
</component>
+
+ <component>
+ <component-type>org.jboss.portal.core.Portlet</component-type>
+ <component-class>org.jboss.portal.core.faces.UIPortlet</component-class>
+ </component>
<render-kit>
<renderer>
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml 2007-03-05 20:20:08 UTC (rev 6545)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml 2007-03-05 21:50:53 UTC (rev 6546)
@@ -4,6 +4,7 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ct="http://www.julien.com"
+ xmlns:jbp="http://www.jboss.org/portal"
xmlns:c="http://java.sun.com/jstl/core">
<ui:composition template="objectTemplate.xhtml">
@@ -102,6 +103,10 @@
</div>
</h:form>
+ <div>
+ <jbp:portlet instanceId="URLPortletInstance"/>
+ </div>
+
</ui:define>
</ui:composition>
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portal.taglib.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portal.taglib.xml 2007-03-05 20:20:08 UTC (rev 6545)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portal.taglib.xml 2007-03-05 21:50:53 UTC (rev 6546)
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE facelet-taglib PUBLIC "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" "facelet-taglib_1_0.dtd">
<facelet-taglib>
- <namespace>http://www.jboss.com/portal</namespace>
+ <namespace>http://www.jboss.org/portal</namespace>
<tag>
<tag-name>scroller</tag-name>
<component>
@@ -9,4 +9,11 @@
<renderer-type>default</renderer-type>
</component>
</tag>
+ <tag>
+ <tag-name>portlet</tag-name>
+ <component>
+ <component-type>org.jboss.portal.core.Portlet</component-type>
+ <renderer-type>default</renderer-type>
+ </component>
+ </tag>
</facelet-taglib>
\ No newline at end of file
Modified: trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/URLPortlet.java
===================================================================
--- trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/URLPortlet.java 2007-03-05 20:20:08 UTC (rev 6545)
+++ trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/URLPortlet.java 2007-03-05 21:50:53 UTC (rev 6546)
@@ -90,7 +90,6 @@
writer.print("<a href=\"" + whiteURL + "\">white</a><br/>");
//
-// PortletURL actionURL = resp.createActionURL();
writer.print("Parameters :<br/>");
writer.print("<table bgcolor=\"" + color + "\">");
writer.print("<tr><td>Name</td><td>value</td></tr>");
@@ -99,20 +98,21 @@
String name = (String)e.nextElement();
String value = req.getParameter(name);
writer.print("<tr><td>" + name + "</td><td>" + value + "</td></tr>");
-// actionURL.setParameter(name, value);
}
writer.print("</table>");
-/*
+
+ //
+ PortletURL actionURL = resp.createActionURL();
writer.print("<form action=\"" + actionURL.toString() + "\" method=\"post\">");
writer.print("<input type=\"text\" name=\"name\"/>");
writer.print("<input type=\"text\" name=\"value\"/>");
writer.print("<input type=\"submit\" value=\"add\"/>");
writer.print("</form>");
-*/
//
writer.print("<a href=\"" + req.getContextPath() + "/test.txt\">test</a>");
+ //
writer.close();
}
}
\ No newline at end of file
Modified: trunk/portlet/src/main/org/jboss/portal/portlet/PortletParametersStateString.java
===================================================================
--- trunk/portlet/src/main/org/jboss/portal/portlet/PortletParametersStateString.java 2007-03-05 20:20:08 UTC (rev 6545)
+++ trunk/portlet/src/main/org/jboss/portal/portlet/PortletParametersStateString.java 2007-03-05 21:50:53 UTC (rev 6546)
@@ -54,6 +54,25 @@
/** The data. */
private PortletParameters parameters;
+ /**
+ * Factory method that will create the most appropriate form.
+ */
+ public static StateString create(String opaqueValue)
+ {
+ if (opaqueValue == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (opaqueValue.startsWith(JBPNS_PREFIX))
+ {
+ return new PortletParametersStateString(opaqueValue);
+ }
+ else
+ {
+ return new OpaqueStateString(opaqueValue);
+ }
+ }
+
public PortletParametersStateString(String opaqueValue)
{
if (opaqueValue == null)
17 years, 4 months