Author: julien(a)jboss.com
Date: 2008-02-07 06:10:06 -0500 (Thu, 07 Feb 2008)
New Revision: 9831
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/EndPortletChunk.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/StartPortletTitleChunk.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/AbstractURLTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/BodyChunkTagSupport.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/ParamTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/SimpleChunkTagSupport.java
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/BufferingResponse.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/ResponseBuffer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletURLChunk.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/MarkupTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/TitleTag.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/index.jsp
Log:
add support for portleturl tag
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-07
08:31:51 UTC (rev 9830)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/controller/PortletURLRenderer.java 2008-02-07
11:10:06 UTC (rev 9831)
@@ -125,11 +125,14 @@
parameters.put(LIFECYCLE_TYPE, type);
//
- String pageState;
+ String pageState = null;
try
{
- byte[] bytes = stateContext.serialize(pageNS);
- pageState = Tools.toHexString(bytes);
+ if (pageNS != null)
+ {
+ byte[] bytes = stateContext.serialize(pageNS);
+ pageState = Tools.toHexString(bytes);
+ }
}
catch (IOException e)
{
@@ -153,7 +156,10 @@
}
//
- parameters.put(PAGE_STATE, pageState);
+ if (pageState != null)
+ {
+ parameters.put(PAGE_STATE, pageState);
+ }
//
if (containerURL instanceof ActionURL)
@@ -190,7 +196,10 @@
//
StateString navigationalState = renderURL.getNavigationalState();
- parameters.put(NAVIGATIONAL_STATE, navigationalState.getStringValue());
+ if (navigationalState != null)
+ {
+ parameters.put(NAVIGATIONAL_STATE, navigationalState.getStringValue());
+ }
}
}
else
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-07
08:31:51 UTC (rev 9830)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/ControllerFilter.java 2008-02-07
11:10:06 UTC (rev 9831)
@@ -27,19 +27,28 @@
import org.jboss.portal.portlet.test.jsp.response.CharsChunk;
import org.jboss.portal.portlet.test.jsp.response.portlet.PortletChunk;
import org.jboss.portal.portlet.test.jsp.response.portlet.PortletMarkupChunk;
-import org.jboss.portal.portlet.test.jsp.response.portlet.PortletTitleChunk;
+import org.jboss.portal.portlet.test.jsp.response.portlet.StartPortletTitleChunk;
+import org.jboss.portal.portlet.test.jsp.response.portlet.PortletURLChunk;
+import org.jboss.portal.portlet.test.jsp.response.portlet.EndPortletChunk;
import org.jboss.portal.portlet.test.jsp.response.BufferingResponse;
import org.jboss.portal.portlet.test.jsp.response.ResponseBuffer;
+import org.jboss.portal.portlet.test.controller.PortletURLRenderer;
import org.jboss.portal.portlet.PortletInvoker;
import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.RenderURL;
+import org.jboss.portal.portlet.StateString;
import org.jboss.portal.portlet.invocation.response.PortletInvocationResponse;
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.portlet.controller.PortletController;
+import org.jboss.portal.portlet.controller.impl.state.StateControllerContextImpl;
import org.jboss.portal.portlet.controller.response.ControllerResponse;
import org.jboss.portal.portlet.controller.response.PageUpdateResponse;
import org.jboss.portal.portlet.controller.response.ResourceResponse;
import org.jboss.portal.portlet.controller.state.PageNavigationalState;
+import org.jboss.portal.portlet.controller.state.WindowNavigationalState;
import org.jboss.portal.common.io.IOTools;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -206,6 +215,10 @@
//
Page page = context.getPage();
+ if (pageState == null)
+ {
+ pageState = context.getStateControllerContext().createPageState();
+ }
//
Map<String, PortletInvocationResponse> responses = page.render(context,
pageState);
@@ -216,6 +229,7 @@
//
int count = 0;
+ String windowId = null;
PortletChunk portletChunk = null;
PortletInvocationResponse portletResponse = null;
for (Chunk chunk : page.getChunks())
@@ -235,10 +249,10 @@
else if (chunk instanceof PortletChunk)
{
portletChunk = (PortletChunk)chunk;
- String windowId = "" + count++;
+ windowId = "" + count++;
portletResponse = responses.get(windowId);
}
- else if (chunk instanceof PortletTitleChunk)
+ else if (chunk instanceof StartPortletTitleChunk)
{
if (portletResponse != null)
{
@@ -250,28 +264,76 @@
}
}
}
- else if (chunk instanceof PortletMarkupChunk)
+ else if (chunk instanceof PortletURLChunk)
{
+ final PortletURLChunk portletURL = (PortletURLChunk)chunk;
if (portletResponse != null)
{
if (portletResponse instanceof FragmentResponse)
{
- FragmentResponse fragment = (FragmentResponse)portletResponse;
- if (fragment.getType() != FragmentResponse.TYPE_EMPTY)
+ PortletURLRenderer renderer = new PortletURLRenderer(
+ (StateControllerContextImpl)context.getStateControllerContext(),
+ pageState,
+ windowId,
+ context.getClientRequest(),
+ context.getClientResponse());
+
+ RenderURL url = new RenderURL()
{
- String frag;
- if (fragment.getType() == FragmentResponse.TYPE_BYTES)
+ public StateString getNavigationalState()
{
- frag = fragment.getBytes().toString();
+ return null;
}
- else
+
+ public Map<String, String[]>
getPublicNavigationalStateChanges()
{
- frag = fragment.getChars().toString();
+ return portletURL.getParams();
}
- //
- writer.write(frag);
- writer.flush();
+ public Mode getMode()
+ {
+ return portletURL.getMode();
+ }
+
+ public WindowState getWindowState()
+ {
+ return portletURL.getWindowState();
+ }
+ };
+
+ //
+ String renderedURL = renderer.renderURL(url, null, null, true);
+ writer.write(renderedURL);
+ writer.flush();
+ }
+ }
+ }
+ else if (chunk instanceof PortletMarkupChunk)
+ {
+ if (portletResponse != null)
+ {
+ if (portletResponse instanceof FragmentResponse)
+ {
+ FragmentResponse fragment = (FragmentResponse)portletResponse;
+ WindowNavigationalState windowNS =
pageState.getWindowNavigationalState(windowId);
+ if (windowNS == null ||
windowNS.getWindowState().equals(WindowState.NORMAL))
+ {
+ if (fragment.getType() != FragmentResponse.TYPE_EMPTY)
+ {
+ String frag;
+ if (fragment.getType() == FragmentResponse.TYPE_BYTES)
+ {
+ frag = fragment.getBytes().toString();
+ }
+ else
+ {
+ frag = fragment.getChars().toString();
+ }
+
+ //
+ writer.write(frag);
+ writer.flush();
+ }
}
}
else
@@ -286,6 +348,12 @@
writer.flush();
}
}
+ else if (chunk instanceof EndPortletChunk)
+ {
+ windowId = null;
+ portletChunk = null;
+ portletResponse = null;
+ }
}
out.close();
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java 2008-02-07
08:31:51 UTC (rev 9830)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/Page.java 2008-02-07
11:10:06 UTC (rev 9831)
@@ -62,12 +62,6 @@
public Map<String, PortletInvocationResponse> render(PortletControllerContext
context, PageNavigationalState pageState)
{
- if (pageState == null)
- {
- pageState = context.getStateControllerContext().createPageState();
- }
-
- //
Map<String, PortletInvocationResponse> responses = new HashMap<String,
PortletInvocationResponse>();
//
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/BufferingResponse.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/BufferingResponse.java 2008-02-07
08:31:51 UTC (rev 9830)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/BufferingResponse.java 2008-02-07
11:10:06 UTC (rev 9831)
@@ -65,9 +65,4 @@
{
buffer.close();
}
-
- public void addChunk(Chunk chunk)
- {
- buffer.addChunk(chunk);
- }
}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/ResponseBuffer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/ResponseBuffer.java 2008-02-07
08:31:51 UTC (rev 9830)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/ResponseBuffer.java 2008-02-07
11:10:06 UTC (rev 9831)
@@ -49,11 +49,36 @@
/** . */
private PrintWriter writer;
+ /** . */
+ private boolean muted;
+
+ public boolean isMuted()
+ {
+ return muted;
+ }
+
+ public void setMuted(boolean muted)
+ {
+ this.muted = muted;
+ }
+
public List<Chunk> getChunks()
{
return chunks;
}
+ public void flush()
+ {
+ if (chunkWriter != null)
+ {
+ chunkWriter.writeChunk();
+ }
+ else if (chunkOutputStream != null)
+ {
+ chunkOutputStream.writeChunk();
+ }
+ }
+
public void close()
{
try
@@ -131,10 +156,15 @@
StringBuffer sb = getBuffer();
if (sb.length() > 0)
{
- char[] chars = new char[sb.length()];
- sb.getChars(0, sb.length(), chars, 0);
- CharsChunk chunk = new CharsChunk(chars);
- chunks.add(chunk);
+ if (!muted)
+ {
+ char[] chars = new char[sb.length()];
+ sb.getChars(0, sb.length(), chars, 0);
+ CharsChunk chunk = new CharsChunk(chars);
+ chunks.add(chunk);
+ }
+
+ //
sb.setLength(0);
}
}
@@ -161,12 +191,17 @@
public void writeChunk()
{
- if (bytebuffer.size() > 0)
+ if (bytebuffer.size() > 0 && !muted)
{
- byte[] bytes = bytebuffer.toByteArray();
+ if (!muted)
+ {
+ byte[] bytes = bytebuffer.toByteArray();
+ BytesChunk chunk = new BytesChunk(bytes);
+ chunks.add(chunk);
+ }
+
+ //
bytebuffer.reset();
- BytesChunk chunk = new BytesChunk(bytes);
- chunks.add(chunk);
}
}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/EndPortletChunk.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/EndPortletChunk.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/EndPortletChunk.java 2008-02-07
11:10:06 UTC (rev 9831)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 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.response.portlet;
+
+import org.jboss.portal.portlet.test.jsp.response.Chunk;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class EndPortletChunk extends Chunk
+{
+}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletURLChunk.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletURLChunk.java 2008-02-07
08:31:51 UTC (rev 9830)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletURLChunk.java 2008-02-07
11:10:06 UTC (rev 9831)
@@ -23,11 +23,46 @@
package org.jboss.portal.portlet.test.jsp.response.portlet;
import org.jboss.portal.portlet.test.jsp.response.Chunk;
+import org.jboss.portal.Mode;
+import org.jboss.portal.WindowState;
+import java.util.Map;
+
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
public class PortletURLChunk extends Chunk
{
+
+ /** . */
+ private final Mode mode;
+
+ /** . */
+ private final WindowState windowState;
+
+ /** . */
+ private final Map<String, String[]> params;
+
+ public PortletURLChunk(Mode mode, WindowState windowState, Map<String, String[]>
params)
+ {
+ this.mode = mode;
+ this.windowState = windowState;
+ this.params = params;
+ }
+
+ public Mode getMode()
+ {
+ return mode;
+ }
+
+ public WindowState getWindowState()
+ {
+ return windowState;
+ }
+
+ public Map<String, String[]> getParams()
+ {
+ return params;
+ }
}
Copied:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/StartPortletTitleChunk.java
(from rev 9821,
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/PortletTitleChunk.java)
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/StartPortletTitleChunk.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/response/portlet/StartPortletTitleChunk.java 2008-02-07
11:10:06 UTC (rev 9831)
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 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.response.portlet;
+
+import org.jboss.portal.portlet.test.jsp.response.Chunk;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class StartPortletTitleChunk extends Chunk
+{
+}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/AbstractURLTag.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/AbstractURLTag.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/AbstractURLTag.java 2008-02-07
11:10:06 UTC (rev 9831)
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * 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 javax.servlet.jsp.JspException;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class AbstractURLTag extends BodyChunkTagSupport
+{
+
+ /** . */
+ private Map<String, String[]> params = new HashMap<String, String[]>();
+
+ public void setParam(String name, String value)
+ {
+ params.put(name, new String[]{value});
+ }
+
+ public Map<String, String[]> getParams()
+ {
+ return new HashMap<String, String[]>(params);
+ }
+
+ public void doInitBody() throws JspException
+ {
+ params.clear();
+ }
+}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/BodyChunkTagSupport.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/BodyChunkTagSupport.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/BodyChunkTagSupport.java 2008-02-07
11:10:06 UTC (rev 9831)
@@ -0,0 +1,75 @@
+/******************************************************************************
+ * 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.response.BufferingResponse;
+import org.jboss.portal.portlet.test.jsp.response.Chunk;
+import org.jboss.portal.portlet.test.jsp.response.ResponseBuffer;
+
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import javax.servlet.jsp.JspException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class BodyChunkTagSupport extends BodyTagSupport
+{
+
+ protected final ResponseBuffer getBuffer()
+ {
+ BufferingResponse response = (BufferingResponse)pageContext.getResponse();
+ return response.getBuffer();
+ }
+
+ protected void mute(boolean on) throws JspException
+ {
+ try
+ {
+ pageContext.getOut().flush();
+ BufferingResponse response = (BufferingResponse)pageContext.getResponse();
+ ResponseBuffer buffer = response.getBuffer();
+ buffer.flush();
+ buffer.setMuted(on);
+ }
+ catch (IOException e)
+ {
+ throw new JspException(e);
+ }
+ }
+
+ protected final void addChunk(Chunk chunk) throws JspException
+ {
+ try
+ {
+ pageContext.getOut().flush();
+ BufferingResponse response = (BufferingResponse)pageContext.getResponse();
+ response.getBuffer().addChunk(chunk);
+ }
+ catch (IOException e)
+ {
+ throw new JspException(e);
+ }
+ }
+}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/MarkupTag.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/MarkupTag.java 2008-02-07
08:31:51 UTC (rev 9830)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/MarkupTag.java 2008-02-07
11:10:06 UTC (rev 9831)
@@ -22,26 +22,17 @@
******************************************************************************/
package org.jboss.portal.portlet.test.jsp.taglib;
-import org.jboss.portal.portlet.test.jsp.response.BufferingResponse;
-import org.jboss.portal.portlet.test.jsp.response.portlet.PortletTitleChunk;
+import org.jboss.portal.portlet.test.jsp.response.Chunk;
import org.jboss.portal.portlet.test.jsp.response.portlet.PortletMarkupChunk;
-import javax.servlet.jsp.tagext.SimpleTagSupport;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.PageContext;
-import java.io.IOException;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class MarkupTag extends SimpleTagSupport
+public class MarkupTag extends SimpleChunkTagSupport
{
- public void doTag() throws JspException, IOException
+ protected Chunk doChunkTag()
{
- PageContext pageCtx = (PageContext)getJspContext();
- pageCtx.getOut().flush();
- BufferingResponse response = (BufferingResponse)pageCtx.getResponse();
- response.addChunk(new PortletMarkupChunk());
+ return new PortletMarkupChunk();
}
}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/ParamTag.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/ParamTag.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/ParamTag.java 2008-02-07
11:10:06 UTC (rev 9831)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * 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 javax.servlet.jsp.tagext.SimpleTagSupport;
+import javax.servlet.jsp.JspException;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class ParamTag extends SimpleTagSupport
+{
+
+ /** . */
+ private String name;
+
+ /** . */
+ private String value;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ public void doTag() throws JspException, IOException
+ {
+ AbstractURLTag urlTag =
(AbstractURLTag)SimpleTagSupport.findAncestorWithClass(this, AbstractURLTag.class);
+ urlTag.setParam(name, value);
+ }
+}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java 2008-02-07
08:31:51 UTC (rev 9830)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletTag.java 2008-02-07
11:10:06 UTC (rev 9831)
@@ -22,16 +22,13 @@
******************************************************************************/
package org.jboss.portal.portlet.test.jsp.taglib;
-import org.jboss.portal.portlet.test.jsp.response.BufferingResponse;
import org.jboss.portal.portlet.test.jsp.response.portlet.PortletChunk;
+import org.jboss.portal.portlet.test.jsp.response.portlet.EndPortletChunk;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
import org.jboss.portal.common.util.Tools;
-import javax.servlet.jsp.tagext.SimpleTagSupport;
-import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.PageContext;
import java.io.IOException;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -41,7 +38,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class PortletTag extends BodyTagSupport
+public class PortletTag extends BodyChunkTagSupport
{
/** . */
@@ -164,8 +161,7 @@
}
//
- BufferingResponse response = (BufferingResponse)pageContext.getResponse();
- response.addChunk(new PortletChunk(
+ addChunk(new PortletChunk(
name,
applicationName,
initialMode,
@@ -178,6 +174,9 @@
public int doEndTag() throws JspException
{
+ addChunk(new EndPortletChunk());
+
+ //
return EVAL_PAGE;
}
}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/PortletURLTag.java 2008-02-07
11:10:06 UTC (rev 9831)
@@ -0,0 +1,96 @@
+/******************************************************************************
+ * 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.Mode;
+import org.jboss.portal.WindowState;
+import org.jboss.portal.portlet.test.jsp.response.portlet.PortletURLChunk;
+
+import javax.servlet.jsp.JspException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class PortletURLTag extends AbstractURLTag
+{
+
+ /** . */
+ private String modeValue;
+
+ /** . */
+ private String windowStateValue;
+
+ public String getMode()
+ {
+ return modeValue;
+ }
+
+ public void setMode(String mode)
+ {
+ this.modeValue = mode;
+ }
+
+ public String getWindowState()
+ {
+ return windowStateValue;
+ }
+
+ public void setWindowState(String windowState)
+ {
+ this.windowStateValue = windowState;
+ }
+
+ public int doStartTag() throws JspException
+ {
+ mute(true);
+
+ //
+ return EVAL_BODY_BUFFERED;
+ }
+
+ public int doEndTag() throws JspException
+ {
+ Mode mode = null;
+ if (modeValue != null)
+ {
+ mode = Mode.create(modeValue.trim());
+ }
+
+ //
+ WindowState windowState = null;
+ if (windowStateValue != null)
+ {
+ windowState = WindowState.create(windowStateValue.trim());
+ }
+
+ //
+ addChunk(new PortletURLChunk(mode, windowState, getParams()));
+
+ //
+ mute(false);
+
+ //
+ return EVAL_PAGE;
+ }
+}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/SimpleChunkTagSupport.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/SimpleChunkTagSupport.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/SimpleChunkTagSupport.java 2008-02-07
11:10:06 UTC (rev 9831)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ * 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.response.Chunk;
+import org.jboss.portal.portlet.test.jsp.response.BufferingResponse;
+
+import javax.servlet.jsp.tagext.SimpleTagSupport;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.PageContext;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public abstract class SimpleChunkTagSupport extends SimpleTagSupport
+{
+
+ public final void doTag() throws JspException, IOException
+ {
+ Chunk chunk = doChunkTag();
+
+ //
+ if (chunk != null)
+ {
+ PageContext pageCtx = (PageContext)getJspContext();
+ pageCtx.getOut().flush();
+ BufferingResponse response = (BufferingResponse)pageCtx.getResponse();
+ response.getBuffer().addChunk(chunk);
+ }
+ }
+
+ protected abstract Chunk doChunkTag();
+
+}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/TitleTag.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/TitleTag.java 2008-02-07
08:31:51 UTC (rev 9830)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/jsp/taglib/TitleTag.java 2008-02-07
11:10:06 UTC (rev 9831)
@@ -22,25 +22,17 @@
******************************************************************************/
package org.jboss.portal.portlet.test.jsp.taglib;
-import org.jboss.portal.portlet.test.jsp.response.BufferingResponse;
-import org.jboss.portal.portlet.test.jsp.response.portlet.PortletTitleChunk;
+import org.jboss.portal.portlet.test.jsp.response.Chunk;
+import org.jboss.portal.portlet.test.jsp.response.portlet.StartPortletTitleChunk;
-import javax.servlet.jsp.tagext.SimpleTagSupport;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.PageContext;
-import java.io.IOException;
-
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class TitleTag extends SimpleTagSupport
+public class TitleTag extends SimpleChunkTagSupport
{
- public void doTag() throws JspException, IOException
+ protected Chunk doChunkTag()
{
- PageContext pageCtx = (PageContext)getJspContext();
- pageCtx.getOut().flush();
- BufferingResponse response = (BufferingResponse)pageCtx.getResponse();
- response.addChunk(new PortletTitleChunk());
+ return new StartPortletTitleChunk();
}
}
Modified:
modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/portal.tld
===================================================================
---
modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/portal.tld 2008-02-07
08:31:51 UTC (rev 9830)
+++
modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/portal.tld 2008-02-07
11:10:06 UTC (rev 9831)
@@ -54,4 +54,32 @@
<body-content>empty</body-content>
</tag>
+ <tag>
+ <name>portleturl</name>
+
<tag-class>org.jboss.portal.portlet.test.jsp.taglib.PortletURLTag</tag-class>
+ <body-content>JSP</body-content>
+ <attribute>
+ <name>mode</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <name>windowState</name>
+ <type>java.lang.String</type>
+ </attribute>
+ </tag>
+
+ <tag>
+ <name>param</name>
+
<tag-class>org.jboss.portal.portlet.test.jsp.taglib.ParamTag</tag-class>
+ <body-content>empty</body-content>
+ <attribute>
+ <name>name</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <attribute>
+ <name>value</name>
+ <type>java.lang.String</type>
+ </attribute>
+ </tag>
+
</taglib>
Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp
===================================================================
--- modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp 2008-02-07
08:31:51 UTC (rev 9830)
+++ modules/portlet/trunk/test/src/test/resources/simple-portal-war/index.jsp 2008-02-07
11:10:06 UTC (rev 9831)
@@ -10,6 +10,8 @@
applicationName="google-weather-portlet">
-----------------------------------<br/>
<portal:title/><br/>
+<a href="<portal:portleturl
windowState='minimized'/>">Minimized<a/><br/>
+<a href="<portal:portleturl><portal:param name='zipcode'
value='20855'/></portal:portleturl>">Derwood<a/><br/>
-----------------------------------<br/>
<portal:markup/>
-----------------------------------<br/>