Author: julien(a)jboss.com
Date: 2007-03-13 18:24:32 -0400 (Tue, 13 Mar 2007)
New Revision: 6656
Added:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletDefinitionInvoker.java
trunk/faces/src/main/org/jboss/portal/faces/component/
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFActionContext.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFInvocation.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFPortalContext.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFRenderContext.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFSecurityContext.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFUserContext.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFWindowContext.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletActionEvent.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletEvent.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletHandler.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletListener.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletRenderEvent.java
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/UIPortlet.java
trunk/faces/src/main/org/jboss/portal/faces/component/scroller/
trunk/faces/src/main/org/jboss/portal/faces/component/scroller/ScrollerRenderer.java
trunk/faces/src/main/org/jboss/portal/faces/component/scroller/ScrollerTag.java
trunk/faces/src/main/org/jboss/portal/faces/component/scroller/UIScroller.java
Removed:
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/PortletHandler.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
trunk/core-admin/src/main/org/jboss/portal/faces/scroller/ScrollerRenderer.java
trunk/core-admin/src/main/org/jboss/portal/faces/scroller/ScrollerTag.java
trunk/core-admin/src/main/org/jboss/portal/faces/scroller/UIScroller.java
Modified:
trunk/build/build.xml
trunk/build/ide/intellij/idea60/modules/core-admin/core-admin.iml
trunk/build/ide/intellij/idea60/modules/faces/faces.iml
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
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/portal.taglib.xml
trunk/core/src/main/org/jboss/portal/core/model/instance/Instance.java
trunk/faces/build.xml
Log:
moved JSF portlet component and scroller component to the faces package
Modified: trunk/build/build.xml
===================================================================
--- trunk/build/build.xml 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/build/build.xml 2007-03-13 22:24:32 UTC (rev 6656)
@@ -141,7 +141,7 @@
<group name="portal">
<include
- modules="common, test, api, faces, jems, server, security, identity,
search, format, portlet, portlet-federation, theme, workflow, cms, bridge, samples,
registration, wsrp, core, core-admin, core-cms, core-management, core-samples"/>
+ modules="common, test, api, jems, server, security, identity, search,
format, portlet, bridge, faces, portlet-federation, theme, workflow, cms, samples,
registration, wsrp, core, core-admin, core-cms, core-management, core-samples"/>
</group>
<group name="cms">
@@ -152,10 +152,6 @@
<include modules="common, test, jems, security"/>
</group>
- <group name="faces">
- <include modules="common, test, faces"/>
- </group>
-
<group name="default">
<include groups="portal"/>
</group>
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-13 21:10:18
UTC (rev 6655)
+++ trunk/build/ide/intellij/idea60/modules/core-admin/core-admin.iml 2007-03-13 22:24:32
UTC (rev 6656)
@@ -112,6 +112,15 @@
</orderEntry>
<orderEntry type="module" module-name="bridge" />
<orderEntry type="module" module-name="server" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root
url="jar://$MODULE_DIR$/../../../../../../thirdparty/apache-log4j/lib/log4j.jar!/"
/>
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
<orderEntryProperties />
</component>
<component name="VcsManagerConfiguration">
Modified: trunk/build/ide/intellij/idea60/modules/faces/faces.iml
===================================================================
--- trunk/build/ide/intellij/idea60/modules/faces/faces.iml 2007-03-13 21:10:18 UTC (rev
6655)
+++ trunk/build/ide/intellij/idea60/modules/faces/faces.iml 2007-03-13 22:24:32 UTC (rev
6656)
@@ -74,6 +74,10 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="module" module-name="api" />
+ <orderEntry type="module" module-name="portlet" />
+ <orderEntry type="module" module-name="server" />
+ <orderEntry type="module" module-name="bridge" />
<orderEntryProperties />
</component>
<component name="VcsManagerConfiguration">
Modified: trunk/core/src/main/org/jboss/portal/core/model/instance/Instance.java
===================================================================
--- trunk/core/src/main/org/jboss/portal/core/model/instance/Instance.java 2007-03-13
21:10:18 UTC (rev 6655)
+++ trunk/core/src/main/org/jboss/portal/core/model/instance/Instance.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -37,7 +37,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public interface Instance
+public interface Instance
{
/**
* Return the id.
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-13
21:10:18 UTC (rev 6655)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -54,8 +54,9 @@
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.portlet.PortletDefinitionInvoker;
import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
-import org.jboss.portal.core.faces.PortletActionEvent;
+import org.jboss.portal.faces.component.portlet.PortletActionEvent;
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.security.AuthorizationDomainRegistry;
import org.jboss.portal.security.spi.auth.PortalAuthorizationManagerFactory;
@@ -68,6 +69,7 @@
import org.jboss.portal.theme.ThemeService;
import org.jboss.portal.theme.render.PortalRenderSet;
import org.jboss.portal.theme.strategy.LayoutStrategy;
+import org.jboss.portal.portlet.PortletInvoker;
/** The portal object manager bean. */
public class PortalObjectManagerBean implements Serializable
@@ -145,6 +147,9 @@
/** . */
private List selectedProperties;
+ /** . */
+ private PortletInvoker portletDefinitionInvoker;
+
// Wired services
public List getAvailableContentTypes()
@@ -220,6 +225,7 @@
public void setInstanceContainer(InstanceContainer instanceContainer)
{
this.instanceContainer = instanceContainer;
+ this.portletDefinitionInvoker = new PortletDefinitionInvoker(instanceContainer);
}
public LayoutService getLayoutService()
@@ -304,6 +310,11 @@
// Runtime state
+ public PortletInvoker getPortletDefinitionInvoker()
+ {
+ return portletDefinitionInvoker;
+ }
+
public AbstractAuthorizationBean getAuth()
{
return auth;
Added:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletDefinitionInvoker.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletDefinitionInvoker.java
(rev 0)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/portlet/PortletDefinitionInvoker.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -0,0 +1,174 @@
+/******************************************************************************
+ * 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.portlet.PortletInvoker;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+import org.jboss.portal.portlet.NoSuchPortletException;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.portlet.state.PropertyMap;
+import org.jboss.portal.portlet.state.PropertyChange;
+import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
+import org.jboss.portal.portlet.invocation.PortletInvocation;
+import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.common.invocation.InvocationException;
+
+import java.util.Set;
+import java.util.List;
+import java.util.Iterator;
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * Adapt the instance container as a portlet invoker. Will be removed later when
+ * migrating the instance container to the portlet package will be done in a
+ * suitable form.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class PortletDefinitionInvoker implements PortletInvoker
+{
+
+ /** . */
+ private InstanceContainer instanceContainer;
+
+ public PortletDefinitionInvoker(InstanceContainer instanceContainer)
+ {
+ if (instanceContainer == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ this.instanceContainer = instanceContainer;
+ }
+
+ public Set getPortlets() throws PortletInvokerException
+ {
+ Collection defs = instanceContainer.getDefinitions();
+ Set portlets = new HashSet(defs.size());
+ for (Iterator i = defs.iterator();i.hasNext();)
+ {
+ Instance instance = (Instance)i.next();
+ portlets.add(new PortletDefinition(instance));
+ }
+ return portlets;
+ }
+
+ public Portlet getPortlet(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException
+ {
+ if (portletContext == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ String instanceId = portletContext.getId();
+ Instance instance = instanceContainer.getDefinition(instanceId);
+ if (instance == null)
+ {
+ throw new NoSuchPortletException(instanceId);
+ }
+ return new PortletDefinition(instance);
+ }
+
+ public PortletInvocationResponse invoke(PortletInvocation invocation) throws
IllegalArgumentException, PortletInvokerException
+ {
+ if (invocation == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ PortletContext portletContext =
(PortletContext)invocation.getAttribute(PortletInvocation.REQUEST_SCOPE,
PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE);
+ if (portletContext == null)
+ {
+ throw new InvocationException("No portlet context provided");
+ }
+ String instanceId = portletContext.getId();
+ Instance instance = instanceContainer.getDefinition(instanceId);
+ if (instance == null)
+ {
+ throw new NoSuchPortletException(instanceId);
+ }
+ return instance.invoke(invocation);
+ }
+
+ public PortletContext createClone(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public List destroyClones(List portletContexts) throws IllegalArgumentException,
PortletInvokerException, UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public PropertyMap getProperties(PortletContext portletContext, Set keys) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public PropertyMap getProperties(PortletContext portletContext) throws
IllegalArgumentException, PortletInvokerException, UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public PortletContext setProperties(PortletContext portletContext, PropertyChange[]
changes) throws IllegalArgumentException, PortletInvokerException,
UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ private static final class PortletDefinition implements Portlet
+ {
+
+ /** . */
+ private final PortletContext ctx;
+
+ /** . */
+ private final PortletInfo info;
+
+ /** . */
+ private final boolean remote;
+
+ public PortletDefinition(Instance instance) throws PortletInvokerException
+ {
+ this.ctx = PortletContext.createPortletContext(instance.getId());
+ this.info = instance.getPortlet().getInfo();
+ this.remote = instance.getPortlet().isRemote();
+ }
+
+ public PortletContext getContext()
+ {
+ return ctx;
+ }
+
+ public PortletInfo getInfo()
+ {
+ return info;
+ }
+
+ public boolean isRemote()
+ {
+ return remote;
+ }
+ }
+}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFActionContext.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFActionContext.java 2007-03-13
21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFActionContext.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -1,83 +0,0 @@
-/******************************************************************************
- * 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);
- }
-}
Deleted: 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-13
21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFInvocation.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -1,195 +0,0 @@
-/******************************************************************************
- * 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.PortletParameters;
-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();
- PortletInvocation portletInvocation = info.getInvocation();
- this.clientRequest = portletInvocation.getDispatchedRequest();
- this.clientResponse = portletInvocation.getDispatchedResponse();
- this.faces = faces;
- this.uiportlet = uiportlet;
-
- //
- this.portalContext = new JSFPortalContext(faces, uiportlet);
- 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,
- PortletParameters navState) throws PortletInvokerException
- {
- //
- RenderContext renderContext = new JSFRenderContext(
- mode,
- windowState,
- navState,
- 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);
- }
-}
Deleted: 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-13
21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFPortalContext.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -1,118 +0,0 @@
-/******************************************************************************
- * 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;
-import java.util.Iterator;
-import java.util.HashSet;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class JSFPortalContext implements PortalContext
-{
-
- /** . */
- private static final Set defaultModes = Collections.unmodifiableSet(Tools.toSet(new
Mode[]{Mode.VIEW,Mode.EDIT,Mode.HELP}));
-
- /** . */
- private static final Set defaultWindowStates =
Collections.unmodifiableSet(Tools.toSet(new
WindowState[]{WindowState.NORMAL,WindowState.MINIMIZED,WindowState.MAXIMIZED}));
-
- /** . */
- private final 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;
- }
-
- public Map getProperties()
- {
- return Collections.EMPTY_MAP;
- }
-}
Deleted: 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-13
21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFRenderContext.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -1,85 +0,0 @@
-/******************************************************************************
- * 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.PortletParameters;
-import org.jboss.portal.portlet.PortletParametersStateString;
-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,
- PortletParameters navState,
- HTTPStreamInfo streamInfo,
- JSFInvocation invocation)
- {
- super(mode, windowState, navState != null ? new
PortletParametersStateString(navState) : null, 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);
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFSecurityContext.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFSecurityContext.java 2007-03-13
21:10:18 UTC (rev 6655)
+++
trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFSecurityContext.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -1,74 +0,0 @@
-/******************************************************************************
- * 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);
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFUserContext.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFUserContext.java 2007-03-13
21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFUserContext.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -1,67 +0,0 @@
-/******************************************************************************
- * 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());
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFWindowContext.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFWindowContext.java 2007-03-13
21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/JSFWindowContext.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -1,56 +0,0 @@
-/******************************************************************************
- * 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;
- }
-}
Deleted: 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-13
21:10:18 UTC (rev 6655)
+++
trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletActionEvent.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -1,149 +0,0 @@
-/******************************************************************************
- * 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.PortletParametersStateString;
-import org.jboss.portal.portlet.PortletParameters;
-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 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()
- {
- 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();
-
- // 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, windowState,
new PortletParametersStateString(interactionState));
- if (pir instanceof RenderResponse)
- {
- RenderResponse render = (RenderResponse)pir;
-
- //
-
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)
- {
- e.printStackTrace();
- }
- }
-}
Deleted: 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-13
21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletEvent.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -1,56 +0,0 @@
-/******************************************************************************
- * 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.event.ActionEvent;
-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 ActionEvent
-{
-
- 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)
- {
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletHandler.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletHandler.java 2007-03-13
21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletHandler.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -1,106 +0,0 @@
-/******************************************************************************
- * 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;
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletListener.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletListener.java 2007-03-13
21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletListener.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -1,34 +0,0 @@
-/******************************************************************************
- * 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);
-}
Deleted: 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-13
21:10:18 UTC (rev 6655)
+++
trunk/core-admin/src/main/org/jboss/portal/core/faces/PortletRenderEvent.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -1,102 +0,0 @@
-/******************************************************************************
- * 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.PortletParameters;
-import org.jboss.portal.WindowState;
-import org.jboss.portal.Mode;
-
-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 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()
- {
- 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.setInternalNavState(navState);
-
- //
- if (windowState != null)
- {
-
- uiportlet.setInternalWindowState(windowState);
- }
-
- //
- if (mode != null)
- {
- uiportlet.setInternalMode(mode);
- }
- }
-}
Deleted: 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-13
21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/core/faces/UIPortlet.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -1,593 +0,0 @@
-/******************************************************************************
- * 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.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.UICommand;
-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;
-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)
- *
- * @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 $
- */
-public class UIPortlet extends UICommand
-{
-
- /** 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;
-
- /** . */
- private String onClick;
-
- /** 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()
- {
- 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 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;
- }
-
- public String getOnClick()
- {
- return onClick;
- }
-
- public void setOnClick(String onClick)
- {
- this.onClick = onClick;
- }
-
- 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)
- {
- Map renderParameters = (Map)vb.getValue(getFacesContext());
- renderParameters.clear();
- renderParameters.putAll(navState);
- }
- else
- {
- this.internalNavState = navState;
- }
- }
-
- PortletParameters getInternalNavState()
- {
- ValueBinding vb = getValueBinding("renderParameters");
- if (vb != null)
- {
- Map renderParameters = (Map)vb.getValue(getFacesContext());
- return PortletParameters.wrap(renderParameters);
- }
- else
- {
- return internalNavState;
- }
- }
-
- public String getFamily()
- {
- return "org.jboss.portal.core.Portlet";
- }
-
- public void broadcast(FacesEvent event) throws AbortProcessingException
- {
- if (event instanceof PortletEvent)
- {
- FacesContext faces = getFacesContext();
-
- //
- MethodBinding listener = getActionListener();
- if (listener != null)
- {
- try
- {
- listener.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);
- }
- else
- {
- super.broadcast(event);
- }
- }
-
- public Object saveState(FacesContext faces)
- {
- String opaqueValue = null;
- if (internalNavState != null)
- {
- opaqueValue = new
PortletParametersStateString(internalNavState).getStringValue();
- }
-
- //
- Object values[] = new Object[11];
- values[0] = super.saveState(faces);
- values[1] = instanceId;
- values[2] = opaqueValue;
- values[3] = saveAttachedState(faces, portletListener);
- values[4] = supportedWindowStates;
- values[5] = supportedModes;
- values[6] = initialWindowState;
- values[7] = initialMode;
- values[8] = internalNavState;
- values[9] = internalMode;
- values[10] = onClick;
- 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];
- internalNavState = serializedNavState != null ? new
PortletParametersStateString(serializedNavState).getParameters() : null;
- portletListener = (MethodBinding)restoreAttachedState(faces, values[3]);
- supportedWindowStates = (Set)values[4];
- supportedModes = (Set)values[5];
- initialWindowState = (String)values[6];
- initialMode = (String)values[7];
- internalNavState = (PortletParameters)values[8];
- internalMode = (Mode)values[9];
- onClick = (String)values[10];
- }
-
- 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);
- Mode mode = decoder.getMode();
- WindowState windowState = decoder.getWindowState();
-
- //
- switch (decoder.getType())
- {
- case PortletRequestDecoder.RENDER_TYPE:
- PortletRenderEvent prevent = new PortletRenderEvent(
- this,
-
((PortletParametersStateString)decoder.getNavigationalState()).getParameters(),
- mode,
- windowState);
- prevent.setPhaseId(PhaseId.INVOKE_APPLICATION);
- queueEvent(prevent);
- break;
- case PortletRequestDecoder.ACTION_TYPE:
- 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;
- }
- }
- }
-
- public void encodeBegin(FacesContext faces) throws IOException
- {
- Instance instance = null;
-
-
- // Resolve instance id
- String instanceId = getInstanceId();
-
- // Get instance
- if (instanceId != null)
- {
- InstanceContainer instanceContainer =
(InstanceContainer)faces.getApplication().getVariableResolver().resolveVariable(faces,
"InstanceContainer");
- instance = instanceContainer.getDefinition(instanceId);
- }
-
- //
- if (instance != null)
- {
- //
- JSFInvocation invocation = new JSFInvocation(faces, this);
-
- //
- try
- {
- PortletInvocationResponse pir = invocation.render(
- instance,
- getInternalMode(),
- getInternalWindowState(),
- getInternalNavState());
-
- //
- if (pir instanceof FragmentResponse)
- {
- FragmentResponse fragment = (FragmentResponse)pir;
- ResponseWriter writer = faces.getResponseWriter();
- writer.startElement("div", this);
- writer.writeAttribute("id", "bilto", null);
- writer.write(fragment.getContent());
- writer.endElement("div");
-
- //
- if (onClick != null)
- {
- writer.startElement("script", this);
- writer.write(
-
- "var isIE = /msie/i.test(navigator.userAgent);\n" +
-
- "function attachEvent(elm, eventName, eventHandler) {\n"
+
- " if (isIE) {\n" +
- " elm.attachEvent(\"on\" + eventName,
eventHandler);\n" +
- " } else {\n" +
- " elm.addEventListener(eventName, eventHandler,
false);\n" +
- " }\n" +
- "}\n" +
-
- "function getEventTarget(event) {\n" +
- " var targetElement = isIE ? event.srcElement :
event.target;\n" +
- " while (targetElement.nodeType == 3 &&
targetElement.parentNode != null) {\n" +
- " targetElement = targetElement.parentNode;\n" +
- " }\n" +
- " return targetElement;\n" +
- "}\n" +
-
- "\n" +
-
- "function PortletURL(url) {\n" +
- " this.params = new Array();\n" +
- " this.url = url;\n" +
- " this.setParameter = function(name, value) {;\n" +
- " this.params[name] = value;\n" +
- " return this;\n" +
- " }\n" +
- " this.toString = function() {;\n" +
- " var tmp = this.url;\n" +
- " for (var i in this.params) {\n" +
- " tmp = tmp + ('&' + i + '=' +
this.params[i]);\n" +
- " };\n" +
- " return tmp;\n" +
- " }\n" +
- "}\n" +
-
- "function fx(event) {\n" +
- " var target = getEventTarget(event);\n" +
- " if (target.nodeName == 'INPUT' &&
target.type == 'submit') {\n" +
- " var current = target.parentNode;\n" +
- " while (current.nodeName != 'FORM' &&
current.nodeName != 'BODY') {\n" +
- " current = current.parentNode;\n" +
- " }\n" +
- " if (current.nodeName == 'FORM') {\n" +
- " var action = current.action;\n" +
- " var portletURL = new PortletURL(action);\n" +
- " (function(url){" + onClick +
"})(portletURL);\n" +
- " current.action = portletURL.toString();\n" +
- " } else {\n" +
- " // Really can't do nothing for now\n" +
- " }\n" +
- " }\n" +
- " else if (target.nodeName == 'A') {\n" +
- " var href = target.href;\n" +
- " var portletURL = new PortletURL(href);\n" +
- " (function(url){" + onClick +
"})(portletURL);\n" +
- " target.href = portletURL.toString();\n" +
- " }\n" +
- " \n" +
- "}\n" +
-
- "var elt = document.getElementById('bilto');\n" +
- "attachEvent(elt, 'click', fx);\n"
- );
- writer.endElement("script");
- }
- writer.flush();
- }
- }
- catch (PortletInvokerException e)
- {
- e.printStackTrace();
- }
- }
- else
- {
- System.out.println("Instance not found: " + instanceId);
- }
- }
-
- 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;
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/faces/scroller/ScrollerRenderer.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/faces/scroller/ScrollerRenderer.java 2007-03-13
21:10:18 UTC (rev 6655)
+++
trunk/core-admin/src/main/org/jboss/portal/faces/scroller/ScrollerRenderer.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -1,237 +0,0 @@
-/******************************************************************************
- * 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.faces.scroller;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIData;
-import javax.faces.component.UIForm;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.el.ValueBinding;
-import javax.faces.render.Renderer;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class ScrollerRenderer extends Renderer
-{
-
- private final String PREVIOUS = "Previous";
- private final String NEXT = "Next";
- private final String FIRST = "First";
- private final String LAST = "Last";
-
-
- public void encodeBegin(FacesContext facesContext, UIComponent component) throws
IOException
- {
- // Get Attributes
- String styleClass = (String) getAttribute(facesContext, component,
"styleClass");
- String datatableId = (String) getAttribute(facesContext, component,
"for");
-
- // Get Form Component
- UIComponent formComponent = component;
- while (!(formComponent instanceof UIForm))
- {
- formComponent = formComponent.getParent();
- }
- String formComponentId = formComponent.getClientId(facesContext);
-
- // Get Writer
- ResponseWriter writer = facesContext.getResponseWriter();
-
- // Get UIData
- String id = getId(datatableId, component.getClientId(facesContext));
- UIData data = (UIData) findComponent(facesContext.getViewRoot(), facesContext,
id);
-
- int first = data.getFirst();
- int rowCount = data.getRowCount();
- int pageSize = data.getRows();
- if (pageSize <= 0) pageSize = rowCount;
-
- int pages = rowCount / pageSize;
- if (rowCount % pageSize != 0 ) pages++;
-
- int currentPage = first / pageSize;
- if (first >= rowCount - pageSize) currentPage = pages-1;
-
- int startPage = 0;
- int endPage = pages;
-
- if (currentPage > 0)
- {
- writeLink(writer, component, formComponentId,
component.getClientId(facesContext), PREVIOUS, styleClass);
- }
- if (first < rowCount - pageSize)
- {
- writeLink(writer, component, formComponentId,
component.getClientId(facesContext), NEXT, styleClass);
- }
-
- writeHiddenField(writer, component, component.getClientId(facesContext));
- }
-
- public void decode(FacesContext facesContext, UIComponent component)
- {
- String id = component.getClientId(facesContext);
- Map parameters = facesContext.getExternalContext().getRequestParameterMap();
- String response = (String) parameters.get(id);
-
- String datatableId = (String) getAttribute(facesContext, component,
"for");
-
- // Get UIData
- String dataId = getId(datatableId, component.getClientId(facesContext));
- UIData data = (UIData) findComponent(facesContext.getViewRoot(), facesContext,
dataId);
-
- int first = data.getFirst();
- int rowCount = data.getRowCount();
- int pageSize = data.getRows();
- if (pageSize <= 0) pageSize = rowCount;
-
- if (response.equals(PREVIOUS))
- {
- first -= pageSize;
- }
- else if (response.equals(NEXT))
- {
- first += pageSize;
- }
-
- if (first < 0)
- {
- first = 0;
- }
- data.setFirst(first);
- }
-
-
- private Object getAttribute(FacesContext facesContext, UIComponent component, String
name)
- {
- ValueBinding vb = component.getValueBinding(name);
- if (vb != null)
- {
- return vb.getValue(facesContext);
- }
- else
- {
- return component.getAttributes().get(name);
- }
- }
-
- public String getId(String id, String base)
- {
- String separator = "" + NamingContainer.SEPARATOR_CHAR;
- String[] idSplitted = id.split(separator);
- String[] baseSplitted = base.split(separator);
- StringBuffer buffer = new StringBuffer();
- for (int i=0; i<(baseSplitted.length - idSplitted.length); i++)
- {
- buffer.append(baseSplitted[i]);
- buffer.append(separator);
- }
- buffer.append(id);
- return buffer.toString();
- }
-
- private UIComponent findComponent(UIComponent component, FacesContext facesContext,
String id)
- {
- String componentId = component.getClientId(facesContext);
- if (componentId.equals(id))
- {
- return component;
- }
- Iterator it = component.getChildren().iterator();
- while (it.hasNext())
- {
- UIComponent comp = (UIComponent)it.next();
- UIComponent found = findComponent(comp, facesContext, id);
- if (found != null)
- {
- return found;
- }
-
- }
- return null;
- }
-
- private void writeHiddenField(ResponseWriter writer, UIComponent component, String id)
throws IOException
- {
- writer.startElement("input", component);
- writer.writeAttribute("type", "hidden", null);
- writer.writeAttribute("name", id, null);
- writer.endElement("input");
- }
-
- private void writeLink(ResponseWriter writer, UIComponent component, String
formComponentId, String id, String value, String styleClass) throws IOException
- {
- writer.writeText(" ", null);
- writer.startElement("input", component);
- writer.writeAttribute("value", value, null);
- writer.writeAttribute("type", "submit", null);
- writer.writeAttribute("onclick", onclickCode(formComponentId, id, value),
null);
- if (styleClass != null)
- {
- writer.writeAttribute("class", styleClass, "styleClass");
- }
- writer.endElement("input");
-
- /*
- writer.writeText(" ", null);
- writer.startElement("a", component);
- writer.writeAttribute("href", "#", null);
- writer.writeAttribute("onclick", onclickCode(formComponentId, id, value),
null);
- if (styleClass != null)
- {
- writer.writeAttribute("class", styleClass, "styleClass");
- }
- writer.writeText(value, null);
- writer.endElement("a");
- */
- }
-
- private String onclickCode(String formComponentId, String id, String value)
- {
- StringBuffer buffer = new StringBuffer();
- buffer.append("document.forms[");
- buffer.append("'");
- buffer.append(formComponentId);
- buffer.append("']");
- buffer.append(".elements['");
- buffer.append(id);
- buffer.append("'].value='");
- buffer.append(value);
- buffer.append("';");
- buffer.append(" document.forms[");
- buffer.append("'");
- buffer.append(formComponentId);
- buffer.append("'");
- buffer.append("].submit()");
- buffer.append("; return false;");
- return buffer.toString();
- }
-
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/faces/scroller/ScrollerTag.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/faces/scroller/ScrollerTag.java 2007-03-13
21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/faces/scroller/ScrollerTag.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -1,95 +0,0 @@
-/******************************************************************************
- * 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.faces.scroller;
-
-import javax.faces.application.Application;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-import javax.faces.webapp.UIComponentTag;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class ScrollerTag extends UIComponentTag
-{
-
- private String _for;
- private String styleClass;
-
- public String getComponentType()
- {
- return "com.jboss.portal.Scroller";
- }
-
- public String getRendererType()
- {
- return "default";
- }
-
- public void setFor(String _for)
- {
- this._for = _for;
- }
-
- public void setStyleClass(String styleClass)
- {
- this.styleClass = styleClass;
- }
-
- public void setProperties(UIComponent component)
- {
- super.setProperties(component);
- setString(component, "for", _for);
- setString(component, "styleClass", styleClass);
- }
-
- private void setString(UIComponent component, String attributeName, String
attributeValue)
- {
- if (attributeValue == null) return;
- if (isValueReference(attributeValue))
- {
- setValueBinding(component, attributeName, attributeValue);
- }
- else
- {
- component.getAttributes().put(attributeName, attributeValue);
- }
- }
-
- private void setValueBinding(UIComponent component, String attributeName, String
attributeValue)
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- Application app = facesContext.getApplication();
- ValueBinding vb = app.createValueBinding(attributeValue);
- component.setValueBinding(attributeName, vb);
- }
-
- public void release()
- {
- super.release();
- _for = null;
- styleClass = null;
- }
-}
Deleted: trunk/core-admin/src/main/org/jboss/portal/faces/scroller/UIScroller.java
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/faces/scroller/UIScroller.java 2007-03-13
21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/main/org/jboss/portal/faces/scroller/UIScroller.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -1,37 +0,0 @@
-/******************************************************************************
- * 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.faces.scroller;
-
-import javax.faces.component.UIInput;
-
-/**
- * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
- * @version $Revision$
- */
-public class UIScroller extends UIInput
-{
- public UIScroller()
- {
- setRendererType("default");
- }
-}
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-13
21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2007-03-13
22:24:32 UTC (rev 6656)
@@ -297,20 +297,20 @@
</lifecycle>
<component>
- <component-type>com.jboss.portal.Scroller</component-type>
-
<component-class>org.jboss.portal.faces.scroller.UIScroller</component-class>
+ <component-type>org.jboss.portal.Scroller</component-type>
+
<component-class>org.jboss.portal.faces.component.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-type>org.jboss.portal.Portlet</component-type>
+
<component-class>org.jboss.portal.faces.component.portlet.UIPortlet</component-class>
</component>
<render-kit>
<renderer>
<component-family>javax.faces.Input</component-family>
<renderer-type>default</renderer-type>
-
<renderer-class>org.jboss.portal.faces.scroller.ScrollerRenderer</renderer-class>
+
<renderer-class>org.jboss.portal.faces.component.scroller.ScrollerRenderer</renderer-class>
</renderer>
</render-kit>
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-13
21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss_portal.tld 2007-03-13
22:24:32 UTC (rev 6656)
@@ -10,7 +10,7 @@
<tag>
<name>scroller</name>
- <tag-class>org.jboss.portal.faces.scroller.ScrollerTag</tag-class>
+
<tag-class>org.jboss.portal.faces.component.scroller.ScrollerTag</tag-class>
<attribute>
<name>for</name>
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-13
21:10:18 UTC (rev 6655)
+++
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editPageLayout.xhtml 2007-03-13
22:24:32 UTC (rev 6656)
@@ -124,7 +124,8 @@
<td class="widget">
<div style="margin-top:3em;">
<jbp:portlet
-
instanceId="#{portalobjectmgr.selectedContentEditorInstance}"
+
portletId="#{portalobjectmgr.selectedContentEditorInstance}"
+
portletInvoker="#{portalobjectmgr.portletDefinitionInvoker}"
actionListener="#{portalobjectmgr.processEvent}"
supportedModes="edit_content"
supportedWindowStates="normal"
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-13
21:10:18 UTC (rev 6655)
+++
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jsf/editWindow.xhtml 2007-03-13
22:24:32 UTC (rev 6656)
@@ -13,7 +13,8 @@
<div>
<jbp:portlet
actionListener="#{portalobjectmgr.processEvent}"
- instanceId="#{portalobjectmgr.selectedContentEditorInstance}"
+ portletId="#{portalobjectmgr.selectedContentEditorInstance}"
+ portletInvoker="#{portalobjectmgr.portletDefinitionInvoker}"
renderParameters="#{portalobjectmgr.renderParameters}"
supportedModes="edit_content"
supportedWindowStates="normal"
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-13
21:10:18 UTC (rev 6655)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/portal.taglib.xml 2007-03-13
22:24:32 UTC (rev 6656)
@@ -5,16 +5,16 @@
<tag>
<tag-name>scroller</tag-name>
<component>
- <component-type>com.jboss.portal.Scroller</component-type>
+ <component-type>org.jboss.portal.Scroller</component-type>
<renderer-type>default</renderer-type>
</component>
</tag>
<tag>
<tag-name>portlet</tag-name>
<component>
- <component-type>org.jboss.portal.core.Portlet</component-type>
+ <component-type>org.jboss.portal.Portlet</component-type>
<renderer-type>default</renderer-type>
-
<handler-class>org.jboss.portal.core.faces.PortletHandler</handler-class>
+
<handler-class>org.jboss.portal.faces.component.portlet.PortletHandler</handler-class>
</component>
</tag>
</facelet-taglib>
\ No newline at end of file
Modified: trunk/faces/build.xml
===================================================================
--- trunk/faces/build.xml 2007-03-13 21:10:18 UTC (rev 6655)
+++ trunk/faces/build.xml 2007-03-13 22:24:32 UTC (rev 6656)
@@ -102,6 +102,9 @@
<path id="dependentmodule.classpath">
<path refid="jboss.portlet-api.classpath"/>
<path refid="jboss.portal-common.classpath"/>
+ <path refid="jboss.portal-portlet.classpath"/>
+ <path refid="jboss.portal-server.classpath"/>
+ <path refid="jboss.portal-bridge.classpath"/>
</path>
<!--+=======================================+-->
Added:
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFActionContext.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFActionContext.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFActionContext.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -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.faces.component.portlet;
+
+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/faces/src/main/org/jboss/portal/faces/component/portlet/JSFInvocation.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFInvocation.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFInvocation.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -0,0 +1,198 @@
+/******************************************************************************
+ * 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.faces.component.portlet;
+
+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.Portlet;
+import org.jboss.portal.portlet.PortletInvoker;
+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.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();
+ PortletInvocation portletInvocation = info.getInvocation();
+ this.clientRequest = portletInvocation.getDispatchedRequest();
+ this.clientResponse = portletInvocation.getDispatchedResponse();
+ this.faces = faces;
+ this.uiportlet = uiportlet;
+
+ //
+ this.portalContext = new JSFPortalContext(faces, uiportlet);
+ 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(
+ Portlet portlet,
+ 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(portlet, action);
+ }
+
+ public PortletInvocationResponse render(
+ Portlet portlet,
+ Mode mode,
+ WindowState windowState,
+ PortletParameters navState) throws PortletInvokerException
+ {
+ //
+ RenderContext renderContext = new JSFRenderContext(
+ mode,
+ windowState,
+ navState,
+ new HTTPStreamInfo(MediaType.HTML, "UTF-8"),
+ this);
+
+ //
+ PortletInvocation render = new RenderInvocation(renderContext);
+
+ //
+ return invoke(portlet, render);
+ }
+
+ private PortletInvocationResponse invoke(
+ Portlet portlet,
+ PortletInvocation invocation) throws PortletInvokerException
+ {
+ //
+ invocation.setPortalContext(portalContext);
+ invocation.setSecurityContext(securityContext);
+ invocation.setUserContext(userContext);
+ invocation.setRequestContext(requestContext);
+ invocation.setWindowContext(windowContext);
+
+ //
+ invocation.setAttribute(PortletInvocation.REQUEST_SCOPE,
PortletInvocation.PORTLET_CONTEXT_ATTRIBUTE, portlet.getContext());
+ PortletInvoker invoker = uiportlet.getPortletInvoker();
+ return invoker.invoke(invocation);
+ }
+}
Added:
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFPortalContext.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFPortalContext.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFPortalContext.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * 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.faces.component.portlet;
+
+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;
+import java.util.Iterator;
+import java.util.HashSet;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class JSFPortalContext implements PortalContext
+{
+
+ /** . */
+ private static final Set defaultModes = Collections.unmodifiableSet(Tools.toSet(new
Mode[]{Mode.VIEW,Mode.EDIT,Mode.HELP}));
+
+ /** . */
+ private static final Set defaultWindowStates =
Collections.unmodifiableSet(Tools.toSet(new
WindowState[]{WindowState.NORMAL,WindowState.MINIMIZED,WindowState.MAXIMIZED}));
+
+ /** . */
+ private final 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;
+ }
+
+ public Map getProperties()
+ {
+ return Collections.EMPTY_MAP;
+ }
+}
Added:
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFRenderContext.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFRenderContext.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFRenderContext.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * 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.faces.component.portlet;
+
+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;
+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,
+ PortletParameters navState,
+ HTTPStreamInfo streamInfo,
+ JSFInvocation invocation)
+ {
+ super(mode, windowState, navState != null ? new
PortletParametersStateString(navState) : null, 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/faces/src/main/org/jboss/portal/faces/component/portlet/JSFSecurityContext.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFSecurityContext.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFSecurityContext.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -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.faces.component.portlet;
+
+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/faces/src/main/org/jboss/portal/faces/component/portlet/JSFUserContext.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFUserContext.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFUserContext.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -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.faces.component.portlet;
+
+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/faces/src/main/org/jboss/portal/faces/component/portlet/JSFWindowContext.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFWindowContext.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/JSFWindowContext.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -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.faces.component.portlet;
+
+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/faces/src/main/org/jboss/portal/faces/component/portlet/PortletActionEvent.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletActionEvent.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletActionEvent.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -0,0 +1,146 @@
+/******************************************************************************
+ * 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.faces.component.portlet;
+
+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.PortletParametersStateString;
+import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.portlet.Portlet;
+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 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()
+ {
+ 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();
+
+ // Get portlet
+ Portlet portlet = uiportlet.getPortlet();
+
+ //
+ JSFInvocation invocation = new JSFInvocation(faces, uiportlet);
+
+ //
+ try
+ {
+ PortletInvocationResponse pir = invocation.action(portlet, mode, windowState,
new PortletParametersStateString(interactionState));
+ if (pir instanceof RenderResponse)
+ {
+ RenderResponse render = (RenderResponse)pir;
+
+ //
+
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)
+ {
+ e.printStackTrace();
+ }
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletEvent.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletEvent.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletEvent.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -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.faces.component.portlet;
+
+import javax.faces.event.FacesListener;
+import javax.faces.event.ActionEvent;
+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 ActionEvent
+{
+
+ 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/faces/src/main/org/jboss/portal/faces/component/portlet/PortletHandler.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletHandler.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletHandler.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -0,0 +1,105 @@
+/******************************************************************************
+ * 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.faces.component.portlet;
+
+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.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;
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletListener.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletListener.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletListener.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -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.faces.component.portlet;
+
+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/faces/src/main/org/jboss/portal/faces/component/portlet/PortletRenderEvent.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletRenderEvent.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/PortletRenderEvent.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * 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.faces.component.portlet;
+
+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;
+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 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()
+ {
+ 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.setInternalNavState(navState);
+
+ //
+ if (windowState != null)
+ {
+
+ uiportlet.setInternalWindowState(windowState);
+ }
+
+ //
+ if (mode != null)
+ {
+ uiportlet.setInternalMode(mode);
+ }
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/portlet/UIPortlet.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/portlet/UIPortlet.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/UIPortlet.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -0,0 +1,631 @@
+/******************************************************************************
+ * 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.faces.component.portlet;
+
+import org.jboss.portal.portlet.impl.PortletRequestDecoder;
+import org.jboss.portal.portlet.PortletParametersStateString;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.PortletParameters;
+import org.jboss.portal.portlet.PortletInvoker;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletContext;
+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.UICommand;
+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;
+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 portlet 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 $
+ */
+public class UIPortlet extends UICommand
+{
+
+ /** The portlet invoker. */
+ private PortletInvoker portletInvoker;
+
+ /** The portlet id. */
+ private String portletId;
+
+ /** 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;
+
+ /** . */
+ private String onClick;
+
+ /** The internal nav state. */
+ private PortletParameters internalNavState;
+
+ /** The internal window state value. */
+ private WindowState internalWindowState;
+
+ /** The internal mode value. */
+ private Mode internalMode;
+
+ public PortletInvoker getPortletInvoker()
+ {
+ if (portletInvoker != null)
+ {
+ return portletInvoker;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("portletInvoker");
+ if (vb != null)
+ {
+ return (PortletInvoker)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setPortletInvoker(PortletInvoker portletInvoker)
+ {
+ this.portletInvoker = portletInvoker;
+ }
+
+ public String getPortletId()
+ {
+ if (portletId != null)
+ {
+ return portletId;
+ }
+
+ //
+ ValueBinding vb = getValueBinding("portletId");
+ if (vb != null)
+ {
+ return (String)vb.getValue(getFacesContext());
+ }
+
+ //
+ return null;
+ }
+
+ public void setPortletId(String portletId)
+ {
+ this.portletId = portletId;
+ }
+
+ 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;
+ }
+
+ public String getOnClick()
+ {
+ return onClick;
+ }
+
+ public void setOnClick(String onClick)
+ {
+ this.onClick = onClick;
+ }
+
+ 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)
+ {
+ Map renderParameters = (Map)vb.getValue(getFacesContext());
+ renderParameters.clear();
+ renderParameters.putAll(navState);
+ }
+ else
+ {
+ this.internalNavState = navState;
+ }
+ }
+
+ PortletParameters getInternalNavState()
+ {
+ ValueBinding vb = getValueBinding("renderParameters");
+ if (vb != null)
+ {
+ Map renderParameters = (Map)vb.getValue(getFacesContext());
+ return PortletParameters.wrap(renderParameters);
+ }
+ else
+ {
+ return internalNavState;
+ }
+ }
+
+ Portlet getPortlet()
+ {
+ String portletId = getPortletId();
+
+ //
+ if (portletId != null)
+ {
+ try
+ {
+ PortletInvoker portletInvoker = getPortletInvoker();
+ return
portletInvoker.getPortlet(PortletContext.createPortletContext(portletId));
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ //
+ return null;
+ }
+
+ public String getFamily()
+ {
+ return "org.jboss.portal.core.Portlet";
+ }
+
+ public void broadcast(FacesEvent event) throws AbortProcessingException
+ {
+ if (event instanceof PortletEvent)
+ {
+ FacesContext faces = getFacesContext();
+
+ //
+ MethodBinding listener = getActionListener();
+ if (listener != null)
+ {
+ try
+ {
+ listener.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);
+ }
+ else
+ {
+ super.broadcast(event);
+ }
+ }
+
+ public Object saveState(FacesContext faces)
+ {
+ String opaqueValue = null;
+ if (internalNavState != null)
+ {
+ opaqueValue = new
PortletParametersStateString(internalNavState).getStringValue();
+ }
+
+ //
+ Object values[] = new Object[11];
+ values[0] = super.saveState(faces);
+ values[1] = portletId;
+ values[2] = opaqueValue;
+ values[3] = saveAttachedState(faces, portletListener);
+ values[4] = supportedWindowStates;
+ values[5] = supportedModes;
+ values[6] = initialWindowState;
+ values[7] = initialMode;
+ values[8] = internalNavState;
+ values[9] = internalMode;
+ values[10] = onClick;
+ return values;
+ }
+
+ public void restoreState(FacesContext faces, Object state)
+ {
+ Object values[] = (Object[])state;
+ super.restoreState(faces, values[0]);
+ String serializedNavState = (String)values[2];
+
+ //
+ portletId = (String)values[1];
+ internalNavState = serializedNavState != null ? new
PortletParametersStateString(serializedNavState).getParameters() : null;
+ portletListener = (MethodBinding)restoreAttachedState(faces, values[3]);
+ supportedWindowStates = (Set)values[4];
+ supportedModes = (Set)values[5];
+ initialWindowState = (String)values[6];
+ initialMode = (String)values[7];
+ internalNavState = (PortletParameters)values[8];
+ internalMode = (Mode)values[9];
+ onClick = (String)values[10];
+ }
+
+ 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);
+ Mode mode = decoder.getMode();
+ WindowState windowState = decoder.getWindowState();
+
+ //
+ switch (decoder.getType())
+ {
+ case PortletRequestDecoder.RENDER_TYPE:
+ PortletRenderEvent prevent = new PortletRenderEvent(
+ this,
+
((PortletParametersStateString)decoder.getNavigationalState()).getParameters(),
+ mode,
+ windowState);
+ prevent.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ queueEvent(prevent);
+ break;
+ case PortletRequestDecoder.ACTION_TYPE:
+ 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;
+ }
+ }
+ }
+
+ public void encodeBegin(FacesContext faces) throws IOException
+ {
+ Portlet portlet = getPortlet();
+
+ //
+ if (portlet != null)
+ {
+ //
+ JSFInvocation invocation = new JSFInvocation(faces, this);
+
+ //
+ try
+ {
+ PortletInvocationResponse pir = invocation.render(
+ portlet,
+ getInternalMode(),
+ getInternalWindowState(),
+ getInternalNavState());
+
+ //
+ if (pir instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)pir;
+ ResponseWriter writer = faces.getResponseWriter();
+ writer.startElement("div", this);
+ writer.writeAttribute("id", "bilto", null);
+ writer.write(fragment.getContent());
+ writer.endElement("div");
+
+ //
+ if (onClick != null)
+ {
+ writer.startElement("script", this);
+ writer.write(
+
+ "var isIE = /msie/i.test(navigator.userAgent);\n" +
+
+ "function attachEvent(elm, eventName, eventHandler) {\n"
+
+ " if (isIE) {\n" +
+ " elm.attachEvent(\"on\" + eventName,
eventHandler);\n" +
+ " } else {\n" +
+ " elm.addEventListener(eventName, eventHandler,
false);\n" +
+ " }\n" +
+ "}\n" +
+
+ "function getEventTarget(event) {\n" +
+ " var targetElement = isIE ? event.srcElement :
event.target;\n" +
+ " while (targetElement.nodeType == 3 &&
targetElement.parentNode != null) {\n" +
+ " targetElement = targetElement.parentNode;\n" +
+ " }\n" +
+ " return targetElement;\n" +
+ "}\n" +
+
+ "\n" +
+
+ "function PortletURL(url) {\n" +
+ " this.params = new Array();\n" +
+ " this.url = url;\n" +
+ " this.setParameter = function(name, value) {;\n" +
+ " this.params[name] = value;\n" +
+ " return this;\n" +
+ " }\n" +
+ " this.toString = function() {;\n" +
+ " var tmp = this.url;\n" +
+ " for (var i in this.params) {\n" +
+ " tmp = tmp + ('&' + i + '=' +
this.params[i]);\n" +
+ " };\n" +
+ " return tmp;\n" +
+ " }\n" +
+ "}\n" +
+
+ "function fx(event) {\n" +
+ " var target = getEventTarget(event);\n" +
+ " if (target.nodeName == 'INPUT' &&
target.type == 'submit') {\n" +
+ " var current = target.parentNode;\n" +
+ " while (current.nodeName != 'FORM' &&
current.nodeName != 'BODY') {\n" +
+ " current = current.parentNode;\n" +
+ " }\n" +
+ " if (current.nodeName == 'FORM') {\n" +
+ " var action = current.action;\n" +
+ " var portletURL = new PortletURL(action);\n" +
+ " (function(url){" + onClick +
"})(portletURL);\n" +
+ " current.action = portletURL.toString();\n" +
+ " } else {\n" +
+ " // Really can't do nothing for now\n" +
+ " }\n" +
+ " }\n" +
+ " else if (target.nodeName == 'A') {\n" +
+ " var href = target.href;\n" +
+ " var portletURL = new PortletURL(href);\n" +
+ " (function(url){" + onClick +
"})(portletURL);\n" +
+ " target.href = portletURL.toString();\n" +
+ " }\n" +
+ " \n" +
+ "}\n" +
+
+ "var elt = document.getElementById('bilto');\n" +
+ "attachEvent(elt, 'click', fx);\n"
+ );
+ writer.endElement("script");
+ }
+ writer.flush();
+ }
+ }
+ catch (PortletInvokerException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ else
+ {
+ System.out.println("Portlet not found: " + portletId);
+ }
+ }
+
+ 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;
+ }
+}
Added:
trunk/faces/src/main/org/jboss/portal/faces/component/scroller/ScrollerRenderer.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/scroller/ScrollerRenderer.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/component/scroller/ScrollerRenderer.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -0,0 +1,237 @@
+/******************************************************************************
+ * 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.faces.component.scroller;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIData;
+import javax.faces.component.UIForm;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.el.ValueBinding;
+import javax.faces.render.Renderer;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class ScrollerRenderer extends Renderer
+{
+
+ private final String PREVIOUS = "Previous";
+ private final String NEXT = "Next";
+ private final String FIRST = "First";
+ private final String LAST = "Last";
+
+
+ public void encodeBegin(FacesContext facesContext, UIComponent component) throws
IOException
+ {
+ // Get Attributes
+ String styleClass = (String) getAttribute(facesContext, component,
"styleClass");
+ String datatableId = (String) getAttribute(facesContext, component,
"for");
+
+ // Get Form Component
+ UIComponent formComponent = component;
+ while (!(formComponent instanceof UIForm))
+ {
+ formComponent = formComponent.getParent();
+ }
+ String formComponentId = formComponent.getClientId(facesContext);
+
+ // Get Writer
+ ResponseWriter writer = facesContext.getResponseWriter();
+
+ // Get UIData
+ String id = getId(datatableId, component.getClientId(facesContext));
+ UIData data = (UIData) findComponent(facesContext.getViewRoot(), facesContext,
id);
+
+ int first = data.getFirst();
+ int rowCount = data.getRowCount();
+ int pageSize = data.getRows();
+ if (pageSize <= 0) pageSize = rowCount;
+
+ int pages = rowCount / pageSize;
+ if (rowCount % pageSize != 0 ) pages++;
+
+ int currentPage = first / pageSize;
+ if (first >= rowCount - pageSize) currentPage = pages-1;
+
+ int startPage = 0;
+ int endPage = pages;
+
+ if (currentPage > 0)
+ {
+ writeLink(writer, component, formComponentId,
component.getClientId(facesContext), PREVIOUS, styleClass);
+ }
+ if (first < rowCount - pageSize)
+ {
+ writeLink(writer, component, formComponentId,
component.getClientId(facesContext), NEXT, styleClass);
+ }
+
+ writeHiddenField(writer, component, component.getClientId(facesContext));
+ }
+
+ public void decode(FacesContext facesContext, UIComponent component)
+ {
+ String id = component.getClientId(facesContext);
+ Map parameters = facesContext.getExternalContext().getRequestParameterMap();
+ String response = (String) parameters.get(id);
+
+ String datatableId = (String) getAttribute(facesContext, component,
"for");
+
+ // Get UIData
+ String dataId = getId(datatableId, component.getClientId(facesContext));
+ UIData data = (UIData) findComponent(facesContext.getViewRoot(), facesContext,
dataId);
+
+ int first = data.getFirst();
+ int rowCount = data.getRowCount();
+ int pageSize = data.getRows();
+ if (pageSize <= 0) pageSize = rowCount;
+
+ if (response.equals(PREVIOUS))
+ {
+ first -= pageSize;
+ }
+ else if (response.equals(NEXT))
+ {
+ first += pageSize;
+ }
+
+ if (first < 0)
+ {
+ first = 0;
+ }
+ data.setFirst(first);
+ }
+
+
+ private Object getAttribute(FacesContext facesContext, UIComponent component, String
name)
+ {
+ ValueBinding vb = component.getValueBinding(name);
+ if (vb != null)
+ {
+ return vb.getValue(facesContext);
+ }
+ else
+ {
+ return component.getAttributes().get(name);
+ }
+ }
+
+ public String getId(String id, String base)
+ {
+ String separator = "" + NamingContainer.SEPARATOR_CHAR;
+ String[] idSplitted = id.split(separator);
+ String[] baseSplitted = base.split(separator);
+ StringBuffer buffer = new StringBuffer();
+ for (int i=0; i<(baseSplitted.length - idSplitted.length); i++)
+ {
+ buffer.append(baseSplitted[i]);
+ buffer.append(separator);
+ }
+ buffer.append(id);
+ return buffer.toString();
+ }
+
+ private UIComponent findComponent(UIComponent component, FacesContext facesContext,
String id)
+ {
+ String componentId = component.getClientId(facesContext);
+ if (componentId.equals(id))
+ {
+ return component;
+ }
+ Iterator it = component.getChildren().iterator();
+ while (it.hasNext())
+ {
+ UIComponent comp = (UIComponent)it.next();
+ UIComponent found = findComponent(comp, facesContext, id);
+ if (found != null)
+ {
+ return found;
+ }
+
+ }
+ return null;
+ }
+
+ private void writeHiddenField(ResponseWriter writer, UIComponent component, String id)
throws IOException
+ {
+ writer.startElement("input", component);
+ writer.writeAttribute("type", "hidden", null);
+ writer.writeAttribute("name", id, null);
+ writer.endElement("input");
+ }
+
+ private void writeLink(ResponseWriter writer, UIComponent component, String
formComponentId, String id, String value, String styleClass) throws IOException
+ {
+ writer.writeText(" ", null);
+ writer.startElement("input", component);
+ writer.writeAttribute("value", value, null);
+ writer.writeAttribute("type", "submit", null);
+ writer.writeAttribute("onclick", onclickCode(formComponentId, id, value),
null);
+ if (styleClass != null)
+ {
+ writer.writeAttribute("class", styleClass, "styleClass");
+ }
+ writer.endElement("input");
+
+ /*
+ writer.writeText(" ", null);
+ writer.startElement("a", component);
+ writer.writeAttribute("href", "#", null);
+ writer.writeAttribute("onclick", onclickCode(formComponentId, id, value),
null);
+ if (styleClass != null)
+ {
+ writer.writeAttribute("class", styleClass, "styleClass");
+ }
+ writer.writeText(value, null);
+ writer.endElement("a");
+ */
+ }
+
+ private String onclickCode(String formComponentId, String id, String value)
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("document.forms[");
+ buffer.append("'");
+ buffer.append(formComponentId);
+ buffer.append("']");
+ buffer.append(".elements['");
+ buffer.append(id);
+ buffer.append("'].value='");
+ buffer.append(value);
+ buffer.append("';");
+ buffer.append(" document.forms[");
+ buffer.append("'");
+ buffer.append(formComponentId);
+ buffer.append("'");
+ buffer.append("].submit()");
+ buffer.append("; return false;");
+ return buffer.toString();
+ }
+
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/scroller/ScrollerTag.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/scroller/ScrollerTag.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/component/scroller/ScrollerTag.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -0,0 +1,95 @@
+/******************************************************************************
+ * 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.faces.component.scroller;
+
+import javax.faces.application.Application;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.webapp.UIComponentTag;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class ScrollerTag extends UIComponentTag
+{
+
+ private String _for;
+ private String styleClass;
+
+ public String getComponentType()
+ {
+ return "com.jboss.portal.Scroller";
+ }
+
+ public String getRendererType()
+ {
+ return "default";
+ }
+
+ public void setFor(String _for)
+ {
+ this._for = _for;
+ }
+
+ public void setStyleClass(String styleClass)
+ {
+ this.styleClass = styleClass;
+ }
+
+ public void setProperties(UIComponent component)
+ {
+ super.setProperties(component);
+ setString(component, "for", _for);
+ setString(component, "styleClass", styleClass);
+ }
+
+ private void setString(UIComponent component, String attributeName, String
attributeValue)
+ {
+ if (attributeValue == null) return;
+ if (isValueReference(attributeValue))
+ {
+ setValueBinding(component, attributeName, attributeValue);
+ }
+ else
+ {
+ component.getAttributes().put(attributeName, attributeValue);
+ }
+ }
+
+ private void setValueBinding(UIComponent component, String attributeName, String
attributeValue)
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ Application app = facesContext.getApplication();
+ ValueBinding vb = app.createValueBinding(attributeValue);
+ component.setValueBinding(attributeName, vb);
+ }
+
+ public void release()
+ {
+ super.release();
+ _for = null;
+ styleClass = null;
+ }
+}
Added: trunk/faces/src/main/org/jboss/portal/faces/component/scroller/UIScroller.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/component/scroller/UIScroller.java
(rev 0)
+++
trunk/faces/src/main/org/jboss/portal/faces/component/scroller/UIScroller.java 2007-03-13
22:24:32 UTC (rev 6656)
@@ -0,0 +1,37 @@
+/******************************************************************************
+ * 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.faces.component.scroller;
+
+import javax.faces.component.UIInput;
+
+/**
+ * @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @version $Revision$
+ */
+public class UIScroller extends UIInput
+{
+ public UIScroller()
+ {
+ setRendererType("default");
+ }
+}