From portal-commits at lists.jboss.org Mon Nov 17 12:42:10 2008 Content-Type: multipart/mixed; boundary="===============2330740735694945109==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r12299 - in modules/portlet/trunk: samples/src/main/artifacts/basic-portlet-war/WEB-INF and 1 other directories. Date: Mon, 17 Nov 2008 12:42:10 -0500 Message-ID: --===============2330740735694945109== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: chris.laprun(a)jboss.com Date: 2008-11-17 12:42:10 -0500 (Mon, 17 Nov 2008) New Revision: 12299 Added: modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/sam= ples/basic/AJAXResourcePortlet.java modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/sam= ples/basic/HeaderInjectionPortlet.java Removed: modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/sam= ples/basic/HeaderPortlet.java Modified: modules/portlet/trunk/portal/src/main/resources/simple-portal-war/demo/d= emo3.jsp modules/portlet/trunk/samples/src/main/artifacts/basic-portlet-war/WEB-I= NF/portlet.xml Log: - Renamed HeaderPortlet to AJAXResourcePortlet. - Added HeaderInjectionPortlet. Modified: modules/portlet/trunk/portal/src/main/resources/simple-portal-war= /demo/demo3.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/portal/src/main/resources/simple-portal-war/demo/= demo3.jsp 2008-11-17 14:06:49 UTC (rev 12298) +++ modules/portlet/trunk/portal/src/main/resources/simple-portal-war/demo/= demo3.jsp 2008-11-17 17:42:10 UTC (rev 12299) @@ -16,7 +16,7 @@ = - + Modified: modules/portlet/trunk/samples/src/main/artifacts/basic-portlet-wa= r/WEB-INF/portlet.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=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/samples/src/main/artifacts/basic-portlet-war/WEB-= INF/portlet.xml 2008-11-17 14:06:49 UTC (rev 12298) +++ modules/portlet/trunk/samples/src/main/artifacts/basic-portlet-war/WEB-= INF/portlet.xml 2008-11-17 17:42:10 UTC (rev 12299) @@ -41,8 +41,8 @@ = - HeaderPortlet - org.jboss.portal.portlet.samples.basic.HeaderPortlet<= /portlet-class> + AJAXResourcePortlet + org.jboss.portal.portlet.samples.basic.AJAXResourcePo= rtlet text/html @@ -50,11 +50,25 @@ text/javascript - Header portlet + AJAX resource portlet = + HeaderInjectionPortlet + org.jboss.portal.portlet.samples.basic.HeaderInjectio= nPortlet + + text/html + + + text/javascript + + + Header injection portlet + + + + FailDuringInitPortlet org.jboss.portal.portlet.samples.basic.FailDuringInit= Portlet @@ -176,7 +190,7 @@ = FilterB - HeaderPortlet + AJAXResourcePortlet = Copied: modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portle= t/samples/basic/AJAXResourcePortlet.java (from rev 12254, modules/portlet/t= runk/samples/src/main/java/org/jboss/portal/portlet/samples/basic/HeaderPor= tlet.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/samples/src/main/java/org/jboss/portal/portlet/sa= mples/basic/AJAXResourcePortlet.java (rev 0) +++ modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/sa= mples/basic/AJAXResourcePortlet.java 2008-11-17 17:42:10 UTC (rev 12299) @@ -0,0 +1,179 @@ +/*************************************************************************= ***** + * 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.samples.basic; + +import javax.portlet.GenericPortlet; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; +import javax.portlet.PortletException; +import javax.portlet.ResourceRequest; +import javax.portlet.ResourceResponse; +import javax.portlet.ResourceURL; +import javax.portlet.ActionRequest; +import javax.portlet.ActionResponse; +import javax.portlet.PortletSecurityException; +import javax.portlet.PortletURL; +import javax.portlet.PortletMode; +import java.io.IOException; +import java.io.PrintWriter; + +/** + * @author Julien Viet + * @version $Revision: 630 $ + */ +public class AJAXResourcePortlet extends GenericPortlet +{ + public final static int TITANIUM =3D 0; + public final static int PLATINUM =3D 1; + public final static int GOLD =3D 2; + public final static int SILVER =3D 3; + public final static int TIN =3D 4; + + public void processAction(ActionRequest req, ActionResponse resp) throw= s PortletException, PortletSecurityException, IOException + { + + String repeatText =3D req.getParameter("repeat"); + // set zip as render parameter + if (repeatText !=3D null){ + resp.setRenderParameter("repeat", repeatText); + } + // request view + resp.setPortletMode(PortletMode.VIEW); + + } + public void render(RenderRequest req, RenderResponse resp) throws Portl= etException, IOException + { + ResourceURL resourceURL =3D resp.createResourceURL(); + PortletURL actionURL =3D resp.createActionURL(); + // +// Element elt =3D resp.createElement("script"); +// elt.setAttribute("type", "text/javascript"); +// elt.setAttribute("src", resourceURL.toString()); +// elt.appendChild(elt.getOwnerDocument().createTextNode("")); +// resp.addProperty("script", elt); + + // + + resp.setContentType("text/html"); + PrintWriter writer =3D resp.getWriter(); + writer.print("" + + ""); + + writer.print("" + + "
" + + "

Partial Refresh Repeater Demo

"); + writer.print("" + + "
" + + "
\n" + + " Repeat Demo:
\n= " + + " \n" + + " \n" + + "
\n" + + "
" + + ""); + writer.print("
"= ); +// "" + +// "Cl= ick me to trigger script" + + writer.print("


" + + "

Partial Refresh Product Catalog

" + + "
" + + ""); + writer.print("
"); + resourceURL.setParameter("prodId","1"); + writer.print("Product 1
"); + + resourceURL.setParameter("prodId","2"); + writer.print("Product 2
"); + + resourceURL.setParameter("prodId","3"); + writer.print("Product 3
"); + + writer.print("
"); + writer.print("
" + + "

Product Details

" + + "
" + + ""); + writer.print("
"); + writer.print("
"); + writer.print("
"); + + + + // writer.print(""); + } + + public void serveResource(ResourceRequest req, ResourceResponse resp) t= hrows PortletException, IOException + { + String repeatText =3D req.getParameter("repeat"); + String prodId =3D req.getParameter("prodId"); + + resp.setContentType("text/html"); + PrintWriter writer =3D resp.getWriter(); + if (repeatText !=3D null){ + writer.print("
"+ req.getPrivateParamete= rMap().get("repeat")[0] +"
"); + } + if (prodId !=3D null){ + if (prodId.equals("1")){ + writer.print("
Product ID: "+ prodId= +"" + + "
" + + " B BY BURTON ALPHA
" + + "Sale Price: $314.96 " + + "
"); + } + if (prodId.equals("2")){ + writer.print("
Product ID: "+ prodId= +"" + + "
" + + "FORUM DESTROYER LTD
" + + "$319.99 " + + "
"); + } + if (prodId.equals("3")){ + writer.print("
Product ID: "+ prodId= +"" + + "
" + + "\n" + + "SANTA CRUZ ALLSTAR
" + + "$256.00 " + + "
"); + } + + } + + + + + writer.close(); + } +} Added: modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet= /samples/basic/HeaderInjectionPortlet.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/samples/src/main/java/org/jboss/portal/portlet/sa= mples/basic/HeaderInjectionPortlet.java (rev 0) +++ modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/sa= mples/basic/HeaderInjectionPortlet.java 2008-11-17 17:42:10 UTC (rev 12299) @@ -0,0 +1,54 @@ +/* +* 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.samples.basic; + +import org.w3c.dom.Element; + +import javax.portlet.GenericPortlet; +import javax.portlet.RenderRequest; +import javax.portlet.RenderResponse; +import javax.portlet.MimeResponse; +import javax.portlet.PortletException; +import java.io.IOException; + +/** + * @author Chris Laprun + * @version $Revision$ + */ +public class HeaderInjectionPortlet extends GenericPortlet +{ + + @Override + protected void doView(RenderRequest renderRequest, RenderResponse rende= rResponse) throws PortletException, IOException + { + renderResponse.getWriter().print("Look at browser title!"); + } + + @Override + protected void doHeaders(RenderRequest renderRequest, RenderResponse re= nderResponse) + { + Element element =3D renderResponse.createElement("title"); + element.setTextContent("My new web browser title"); + renderResponse.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, element= ); + } +} Deleted: modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portl= et/samples/basic/HeaderPortlet.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/samples/src/main/java/org/jboss/portal/portlet/sa= mples/basic/HeaderPortlet.java 2008-11-17 14:06:49 UTC (rev 12298) +++ modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/sa= mples/basic/HeaderPortlet.java 2008-11-17 17:42:10 UTC (rev 12299) @@ -1,181 +0,0 @@ -/*************************************************************************= ***** - * 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.samples.basic; - -import javax.portlet.GenericPortlet; -import javax.portlet.RenderRequest; -import javax.portlet.RenderResponse; -import javax.portlet.PortletException; -import javax.portlet.ResourceRequest; -import javax.portlet.ResourceResponse; -import javax.portlet.ResourceURL; -import javax.portlet.ActionRequest; -import javax.portlet.ActionResponse; -import javax.portlet.PortletSecurityException; -import javax.portlet.PortletURL; -import javax.portlet.PortletMode; -import java.io.IOException; -import java.io.PrintWriter; - -/** - * @author Julien Viet - * @version $Revision: 630 $ - */ -public class HeaderPortlet extends GenericPortlet -{ - public final static int TITANIUM =3D 0; - public final static int PLATINUM =3D 1; - public final static int GOLD =3D 2; - public final static int SILVER =3D 3; - public final static int TIN =3D 4; - - public void processAction(ActionRequest req, ActionResponse resp) throw= s PortletException, PortletSecurityException, IOException - { - - String repeatText =3D req.getParameter("repeat"); - // set zip as render parameter - if (repeatText !=3D null){ - resp.setRenderParameter("repeat", repeatText); - } - // request view - resp.setPortletMode(PortletMode.VIEW); - - } - public void render(RenderRequest req, RenderResponse resp) throws Portl= etException, IOException - { - ResourceURL resourceURL =3D resp.createResourceURL(); - PortletURL actionURL =3D resp.createActionURL(); - // -// Element elt =3D resp.createElement("script"); -// elt.setAttribute("type", "text/javascript"); -// elt.setAttribute("src", resourceURL.toString()); -// elt.appendChild(elt.getOwnerDocument().createTextNode("")); -// resp.addProperty("script", elt); - - // - - resp.setContentType("text/html"); - PrintWriter writer =3D resp.getWriter(); - writer.print("" + - ""); - - writer.print("" + - "
" + - "

Partial Refresh Repeater Demo

"); - writer.print("" + - "
" + - "
\n" + - " Repeat Demo:
\n= " + - " \n" + - " \n" + - "
\n" + - "
" + - ""); - writer.print("
"= ); -// "" + -// "Cl= ick me to trigger script" + - writer.print("


" + - "

Partial Refresh Product Catalog

" + - "
" + - ""); - writer.print("
"); - resourceURL.setParameter("prodId","1"); - writer.print("Product 1
"); - - resourceURL.setParameter("prodId","2"); - writer.print("Product 2
"); - - resourceURL.setParameter("prodId","3"); - writer.print("Product 3
"); - - writer.print("
"); - writer.print("
" + - "

Product Details

" + - "
" + - ""); - writer.print("
"); - writer.print("
"); - writer.print("
"); - - - - // writer.print(""); - } - - public void serveResource(ResourceRequest req, ResourceResponse resp) t= hrows PortletException, IOException - { - String repeatText =3D req.getParameter("repeat"); - String prodId =3D req.getParameter("prodId"); - - String namespace =3Dresp.getNamespace(); - //resp.setContentType("application/json"); - resp.setContentType("text/html"); - PrintWriter writer =3D resp.getWriter(); - if (repeatText !=3D null){ - writer.print("
"+ req.getPrivateParamete= rMap().get("repeat")[0] +"
"); - } - if (prodId !=3D null){ - if (prodId.equals("1")){ - writer.print("
Product ID: "+ prodId= +"" + - "
" + - " B BY BURTON ALPHA
" + - "Sale Price: $314.96 " + - "
"); - } - if (prodId.equals("2")){ - writer.print("
Product ID: "+ prodId= +"" + - "
" + - "FORUM DESTROYER LTD
" + - "$319.99 " + - "
"); - } - if (prodId.equals("3")){ - writer.print("
Product ID: "+ prodId= +"" + - "
" + - "\n" + - "SANTA CRUZ ALLSTAR
" + - "$256.00 " + - "
"); - } - - } - - - - - writer.close(); - } -} --===============2330740735694945109==--