From portal-commits at lists.jboss.org Fri Feb 8 18:32:02 2008 Content-Type: multipart/mixed; boundary="===============6222956638655609363==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r9877 - in modules/portlet/trunk/test/src: main/java/org/jboss/portal/portlet/test/jsp/taglib and 2 other directories. Date: Fri, 08 Feb 2008 18:32:02 -0500 Message-ID: --===============6222956638655609363== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: julien(a)jboss.com Date: 2008-02-08 18:32:02 -0500 (Fri, 08 Feb 2008) New Revision: 9877 Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/j= sp/taglib/PageParamTag.java Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/j= sp/PortalResponse.java modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/j= sp/taglib/PageTag.java modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/j= sp/taglib/PortletTag.java modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/= portal.tld modules/portlet/trunk/test/src/test/resources/simple-portal-war/layouts/= default.jsp Log: add page param that allow to set public render param on page before renderi= ng has occured Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet= /test/jsp/PortalResponse.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/= jsp/PortalResponse.java 2008-02-08 22:18:30 UTC (rev 9876) +++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/= jsp/PortalResponse.java 2008-02-08 23:32:02 UTC (rev 9877) @@ -22,16 +22,28 @@ *************************************************************************= *****/ package org.jboss.portal.portlet.test.jsp; = -import org.jboss.portal.portlet.test.jsp.PagePortletControllerContext; +import org.jboss.portal.portlet.test.controller.TestInstanceContext; +import org.jboss.portal.portlet.test.controller.TestPortalContext; import org.jboss.portal.portlet.controller.state.PageNavigationalState; import org.jboss.portal.portlet.controller.state.WindowNavigationalState; +import org.jboss.portal.portlet.invocation.response.PortletInvocationRespo= nse; +import org.jboss.portal.portlet.invocation.RenderInvocation; +import org.jboss.portal.portlet.PortletInvokerException; +import org.jboss.portal.portlet.Portlet; +import org.jboss.portal.portlet.StateString; +import org.jboss.portal.portlet.impl.spi.AbstractClientContext; +import org.jboss.portal.portlet.impl.spi.AbstractServerContext; +import org.jboss.portal.portlet.impl.spi.AbstractUserContext; +import org.jboss.portal.portlet.impl.spi.AbstractWindowContext; +import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext; +import org.jboss.portal.portlet.spi.PortletInvocationContext; import org.jboss.portal.WindowState; +import org.jboss.portal.Mode; +import org.jboss.portal.common.util.ParameterMap; = import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; -import javax.servlet.ServletOutputStream; -import java.io.IOException; -import java.io.PrintWriter; +import javax.xml.namespace.QName; = /** * @author Julien Viet @@ -41,17 +53,17 @@ { = /** . */ -// private final ResponseBuffer buffer =3D new ResponseBuffer(); - - /** . */ private final PagePortletControllerContext portletControllerContext; = /** . */ - private final PageNavigationalState pageState; + private PageNavigationalState pageState; = /** . */ private int count =3D 0; = + /** Wether or not the page state can be modified. */ + private boolean pageStateModifiable; + public PortalResponse( HttpServletResponse response, PagePortletControllerContext portletControllerContext, @@ -62,6 +74,7 @@ // this.portletControllerContext =3D portletControllerContext; this.pageState =3D pageState; + this.pageStateModifiable =3D true; } = /** @@ -74,46 +87,108 @@ return pageState; } = - public String getMaximizedWindowId() + public PortletInvocationResponse render(Portlet portlet, String windowI= d) throws PortletInvokerException { + WindowNavigationalState windowNS =3D null; if (pageState !=3D null) { - for (String windowId : pageState.getWindowIds()) + windowNS =3D pageState.getWindowNavigationalState(windowId); + } + + // + ParameterMap publicNS =3D null; + if (pageState !=3D null) + { + publicNS =3D pageState.getPublicNavigationalState(windowId); + } + + // + Mode mode =3D Mode.VIEW; + WindowState windowState =3D WindowState.NORMAL; + StateString portletNS =3D null; + + // + if (windowNS !=3D null) + { + if (windowNS.getMode() !=3D null) { - WindowNavigationalState windowNS =3D pageState.getWindowNaviga= tionalState(windowId); - if (WindowState.MAXIMIZED.equals(windowNS.getWindowState())) - { - return windowId; - } + mode =3D windowNS.getMode(); } + if (windowNS.getWindowState() !=3D null) + { + windowState =3D windowNS.getWindowState(); + } + if (windowNS.getPortletNavigationalState() !=3D null) + { + portletNS =3D windowNS.getPortletNavigationalState(); + } } = // - return null; + PortletInvocationContext renderContext =3D portletControllerContext.= createPortletInvocationContext(windowId, pageState); + RenderInvocation render =3D new RenderInvocation(renderContext); + render.setClientContext(new AbstractClientContext(portletControllerC= ontext.getClientRequest())); + render.setServerContext(new AbstractServerContext(portletControllerC= ontext.getClientRequest(), portletControllerContext.getClientResponse())); + render.setInstanceContext(new TestInstanceContext(portletControllerC= ontext.getClientRequest(), portlet.getContext(), false)); + render.setUserContext(new AbstractUserContext(portletControllerConte= xt.getClientRequest())); + render.setWindowContext(new AbstractWindowContext(windowId)); + render.setPortalContext(new TestPortalContext()); + render.setSecurityContext(new AbstractSecurityContext(portletControl= lerContext.getClientRequest())); + render.setTarget(portlet.getContext()); + render.setMode(mode); + render.setWindowState(windowState); + render.setNavigationalState(portletNS); + render.setPublicNavigationalState(publicNS); + + // + pageStateModifiable =3D false; + + // + return portletControllerContext.invoke(render); } = - public boolean isRenderable(String windowId) + public boolean isPageStateModifiable() { - if (windowId =3D=3D null) + return pageStateModifiable; + } + + public String getPageParameter(QName name) + { + return pageState !=3D null ? pageState.getPublicNavigationalState(na= me)[0] : null; + } + + public void setPageParameter(QName name, String value) + { + if (pageStateModifiable) { - throw new IllegalArgumentException(); + if (pageState =3D=3D null) + { + pageState =3D portletControllerContext.getStateControllerConte= xt().createPageState(true); + } + pageState.setPublicNavigationalState(name, new String[]{value}); } - - // - if (pageState =3D=3D null) + else { - return false; + throw new IllegalStateException("Page state cannot be modified"); } + } = - // - String maximizedWindowId =3D getMaximizedWindowId(); - if (maximizedWindowId !=3D null) + public String getMaximizedWindowId() + { + if (pageState !=3D null) { - return maximizedWindowId.equals(windowId); + for (String windowId : pageState.getWindowIds()) + { + WindowNavigationalState windowNS =3D pageState.getWindowNaviga= tionalState(windowId); + if (WindowState.MAXIMIZED.equals(windowNS.getWindowState())) + { + return windowId; + } + } } = // - return true; + return null; } = public PagePortletControllerContext getPortletControllerContext() @@ -121,38 +196,8 @@ return portletControllerContext; } = -// public ResponseBuffer getBuffer() -// { -// return buffer; -// } -// -// public ServletOutputStream getOutputStream() throws IOException -// { -// return buffer.getOutputStream(); -// } -// -// public PrintWriter getWriter() throws IOException -// { -// return buffer.getWriter(); -// } -// -// public void close() -// { -// buffer.close(); -// } - public String nextId() { return "" + count++; } - -// public ServletOutputStream getOutputStream() throws IOException -// { -// return out.getOutputStream(); -// } -// -// public PrintWriter getWriter() throws IOException -// { -// return out.getWriter(); -// } } Added: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/te= st/jsp/taglib/PageParamTag.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/= jsp/taglib/PageParamTag.java (rev 0) +++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/= jsp/taglib/PageParamTag.java 2008-02-08 23:32:02 UTC (rev 9877) @@ -0,0 +1,106 @@ +/*************************************************************************= ***** + * JBoss, a division of Red Hat = * + * Copyright 2008, 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.portlet.test.jsp.taglib; + +import org.jboss.portal.portlet.test.jsp.PortalResponse; + +import javax.servlet.jsp.JspException; +import javax.xml.namespace.QName; +import java.io.IOException; + +/** + * @author Julien Viet + * @version $Revision: 630 $ + */ +public class PageParamTag extends PortalSimpleTagSupport +{ + + /** . */ + private String namespaceURI; + + /** . */ + private String localName; + + /** . */ + private String value; + + /** . */ + private String frozen; + + public String getNamespaceURI() + { + return namespaceURI; + } + + public void setNamespaceURI(String namespaceURI) + { + this.namespaceURI =3D namespaceURI; + } + + public String getLocalName() + { + return localName; + } + + public void setLocalName(String localName) + { + this.localName =3D localName; + } + + public String getValue() + { + return value; + } + + public void setValue(String value) + { + this.value =3D value; + } + + public String getFrozen() + { + return frozen; + } + + public void setFrozen(String frozen) + { + this.frozen =3D frozen; + } + + public void internalDoTag() throws JspException, IOException + { + PortalResponse response =3D getPortalResponse(); + + // + if (response.isPageStateModifiable()) + { + QName name =3D new QName(namespaceURI, localName); + + // + if (!"true".equals(frozen) || response.getPageParameter(name) =3D= =3D null) + { + response.setPageParameter(name, value); + } + } + } +} Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet= /test/jsp/taglib/PageTag.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/= jsp/taglib/PageTag.java 2008-02-08 22:18:30 UTC (rev 9876) +++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/= jsp/taglib/PageTag.java 2008-02-08 23:32:02 UTC (rev 9877) @@ -25,7 +25,9 @@ import org.jboss.portal.portlet.test.jsp.PortalResponse; = import javax.servlet.jsp.JspException; +import javax.xml.namespace.QName; import java.io.IOException; +import java.util.Map; = /** * @author Julien Viet @@ -39,10 +41,16 @@ INACTIVE, ACTIVE, SUSPENDED } = + /** . */ + Map params; + + /** . */ String maximizedId; = + /** . */ String content; = + /** . */ Status status =3D Status.INACTIVE; = public int doStartTag() throws JspException Modified: modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet= /test/jsp/taglib/PortletTag.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/= jsp/taglib/PortletTag.java 2008-02-08 22:18:30 UTC (rev 9876) +++ modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/= jsp/taglib/PortletTag.java 2008-02-08 23:32:02 UTC (rev 9877) @@ -24,28 +24,15 @@ = import org.jboss.portal.portlet.test.jsp.PortalResponse; import org.jboss.portal.portlet.test.jsp.PagePortletControllerContext; -import org.jboss.portal.portlet.test.controller.TestInstanceContext; -import org.jboss.portal.portlet.test.controller.TestPortalContext; import org.jboss.portal.portlet.invocation.response.PortletInvocationRespo= nse; import org.jboss.portal.portlet.invocation.response.FragmentResponse; import org.jboss.portal.portlet.invocation.response.ErrorResponse; import org.jboss.portal.portlet.invocation.response.UnavailableResponse; -import org.jboss.portal.portlet.invocation.RenderInvocation; -import org.jboss.portal.portlet.controller.state.PageNavigationalState; -import org.jboss.portal.portlet.controller.state.WindowNavigationalState; -import org.jboss.portal.portlet.StateString; import org.jboss.portal.portlet.PortletInvokerException; import org.jboss.portal.portlet.Portlet; -import org.jboss.portal.portlet.impl.spi.AbstractClientContext; -import org.jboss.portal.portlet.impl.spi.AbstractServerContext; -import org.jboss.portal.portlet.impl.spi.AbstractUserContext; -import org.jboss.portal.portlet.impl.spi.AbstractWindowContext; -import org.jboss.portal.portlet.impl.spi.AbstractSecurityContext; -import org.jboss.portal.portlet.spi.PortletInvocationContext; import org.jboss.portal.Mode; import org.jboss.portal.WindowState; import org.jboss.portal.common.util.Tools; -import org.jboss.portal.common.util.ParameterMap; = import javax.servlet.jsp.JspException; import javax.servlet.RequestDispatcher; @@ -64,15 +51,6 @@ { = /** . */ - private static final int SKIPPED =3D 0; - - /** . */ - private static final int BUFFERED =3D 1; - - /** . */ - private static final int RENDERED =3D 2; - - /** . */ private static final Set DEFAULT_MODES =3D Collections.unmodifiab= leSet(Tools.toSet(Mode.VIEW, Mode.EDIT, Mode.HELP)); = /** . */ @@ -96,7 +74,6 @@ /** . */ private String errorPageAttr; = - private int status; private Set supportedWindowStates; private Set supportedModes; private Mode initialMode; @@ -249,22 +226,15 @@ { if (windowId.equals(pageTag.maximizedId)) { - status =3D BUFFERED; - - // return render(portlet, windowId, EVAL_BODY_BUFFERED); } else { - status =3D SKIPPED; return SKIP_BODY; } } else { - status =3D RENDERED; - - // return render(portlet, windowId, EVAL_BODY_INCLUDE); } } @@ -286,67 +256,9 @@ = public int render(Portlet portlet, String windowId, int rt) { - PagePortletControllerContext context =3D response.getPortletControll= erContext(); - - // - PageNavigationalState pageNS =3D response.getPageState(); - - // - WindowNavigationalState windowNS =3D null; - if (pageNS !=3D null) - { - windowNS =3D pageNS.getWindowNavigationalState(windowId); - } - - // - ParameterMap publicNS =3D null; - if (pageNS !=3D null) - { - publicNS =3D pageNS.getPublicNavigationalState(windowId); - } - - // - Mode mode =3D Mode.VIEW; - WindowState windowState =3D WindowState.NORMAL; - StateString portletNS =3D null; - - // - if (windowNS !=3D null) - { - if (windowNS.getMode() !=3D null) - { - mode =3D windowNS.getMode(); - } - if (windowNS.getWindowState() !=3D null) - { - windowState =3D windowNS.getWindowState(); - } - if (windowNS.getPortletNavigationalState() !=3D null) - { - portletNS =3D windowNS.getPortletNavigationalState(); - } - } - - // - PortletInvocationContext renderContext =3D context.createPortletInvo= cationContext(windowId, pageNS); - RenderInvocation render =3D new RenderInvocation(renderContext); - render.setClientContext(new AbstractClientContext(context.getClientR= equest())); - render.setServerContext(new AbstractServerContext(context.getClientR= equest(), context.getClientResponse())); - render.setInstanceContext(new TestInstanceContext(context.getClientR= equest(), portlet.getContext(), false)); - render.setUserContext(new AbstractUserContext(context.getClientReque= st())); - render.setWindowContext(new AbstractWindowContext(windowId)); - render.setPortalContext(new TestPortalContext()); - render.setSecurityContext(new AbstractSecurityContext(context.getCli= entRequest())); - render.setTarget(portlet.getContext()); - render.setMode(mode); - render.setWindowState(windowState); - render.setNavigationalState(portletNS); - render.setPublicNavigationalState(publicNS); - - // try { - PortletInvocationResponse portletResponse =3D context.invoke(rend= er); + PortletInvocationResponse portletResponse =3D response.render(por= tlet, windowId); = // if (portletResponse instanceof FragmentResponse) Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/W= EB-INF/portal.tld =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF= /portal.tld 2008-02-08 22:18:30 UTC (rev 9876) +++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF= /portal.tld 2008-02-08 23:32:02 UTC (rev 9877) @@ -86,14 +86,45 @@ empty name + true true java.lang.String value + true true java.lang.String = + + pageparam + org.jboss.portal.portlet.test.jsp.taglib.PageParamTag + empty + + namespaceURI + true + true + java.lang.String + + + localName + true + true + java.lang.String + + + value + true + true + java.lang.String + + + frozen + true + java.lang.String + + + Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/l= ayouts/default.jsp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- modules/portlet/trunk/test/src/test/resources/simple-portal-war/layouts= /default.jsp 2008-02-08 22:18:30 UTC (rev 9876) +++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/layouts= /default.jsp 2008-02-08 23:32:02 UTC (rev 9877) @@ -26,6 +26,9 @@ =
+ + + --===============6222956638655609363==--