Author: julien(a)jboss.com
Date: 2007-06-14 17:41:59 -0400 (Thu, 14 Jun 2007)
New Revision: 7424
Added:
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FormAutoSubmitPortlet.java
Modified:
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/default-object.xml
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet-instances.xml
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet.xml
Log:
added a sample portlet which perform programmatic form submit triggered by browser events
Added:
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FormAutoSubmitPortlet.java
===================================================================
---
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FormAutoSubmitPortlet.java
(rev 0)
+++
trunk/core-samples/src/main/org/jboss/portal/core/portlet/test/FormAutoSubmitPortlet.java 2007-06-14
21:41:59 UTC (rev 7424)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * 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.portlet.test;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletURL;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 5448 $
+ */
+public class FormAutoSubmitPortlet extends GenericPortlet
+{
+
+ public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, PortletSecurityException, IOException
+ {
+ }
+
+ protected void doView(RenderRequest req, RenderResponse resp) throws PortletException,
PortletSecurityException, IOException
+ {
+ resp.setContentType("text/html");
+
+ //
+ PrintWriter writer = resp.getWriter();
+ PortletURL actionURL = resp.createActionURL();
+ String formId = resp.getNamespace() + "_the_form";
+
+ //
+ writer.write("<form id=\"" + formId + "\"
action=\"" + actionURL + "\">");
+ writer.write("<select onclick=\"document.getElementById('" +
formId + "').submit()\" multiple=\"multiple\">");
+ writer.write("<option>A</option>");
+ writer.write("<option>B</option>");
+ writer.write("<option>C</option>");
+ writer.write("</select>");
+ writer.write("</form>");
+ writer.write("<a href=\"javascript:document.getElementById('"
+ formId + "').submit()\">submit</a>");
+ }
+}
Modified: trunk/core-samples/src/resources/portal-samples-war/WEB-INF/default-object.xml
===================================================================
---
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/default-object.xml 2007-06-14
21:35:25 UTC (rev 7423)
+++
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/default-object.xml 2007-06-14
21:41:59 UTC (rev 7424)
@@ -305,6 +305,21 @@
<height>0</height>
</window>
</page>
+ <page>
+ <page-name>javascript test</page-name>
+ <window>
+ <window-name>CatalogPortletWindow</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>FormAutoSubmitPortletWindow</window-name>
+ <instance-ref>FormAutoSubmitPortletInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ </page>
</page>
</deployment>
<deployment>
@@ -558,6 +573,21 @@
<height>0</height>
</window>
</page>
+ <page>
+ <page-name>javascript test</page-name>
+ <window>
+ <window-name>CatalogPortletWindow</window-name>
+ <instance-ref>CatalogPortletInstance</instance-ref>
+ <region>left</region>
+ <height>0</height>
+ </window>
+ <window>
+ <window-name>FormAutoSubmitPortletWindow</window-name>
+ <instance-ref>FormAutoSubmitPortletInstance</instance-ref>
+ <region>center</region>
+ <height>0</height>
+ </window>
+ </page>
</page>
</deployment>
</deployments>
Modified:
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet-instances.xml
===================================================================
---
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet-instances.xml 2007-06-14
21:35:25 UTC (rev 7423)
+++
trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet-instances.xml 2007-06-14
21:41:59 UTC (rev 7424)
@@ -164,4 +164,10 @@
<portlet-ref>FileUploadPortlet</portlet-ref>
</instance>
</deployment>
+ <deployment>
+ <instance>
+ <instance-id>FormAutoSubmitPortletInstance</instance-id>
+ <portlet-ref>FormAutoSubmitPortlet</portlet-ref>
+ </instance>
+ </deployment>
</deployments>
\ No newline at end of file
Modified: trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet.xml
===================================================================
--- trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet.xml 2007-06-14
21:35:25 UTC (rev 7423)
+++ trunk/core-samples/src/resources/portal-samples-war/WEB-INF/portlet.xml 2007-06-14
21:41:59 UTC (rev 7424)
@@ -42,7 +42,7 @@
</portlet-info>
</portlet>
<portlet>
- <description>Simple Portlet</description>
+ <description>Event Portlet</description>
<portlet-name>EventPortlet</portlet-name>
<display-name>Event Portlet</display-name>
<portlet-class>org.jboss.samples.portlet.event.EventPortlet</portlet-class>
@@ -388,6 +388,20 @@
<keywords>sample,test</keywords>
</portlet-info>
</portlet>
+ <portlet>
+ <description>Portlet which performs a programmatic submit of a
form</description>
+ <portlet-name>FormAutoSubmitPortlet</portlet-name>
+ <display-name>Form auto submit Portlet</display-name>
+
<portlet-class>org.jboss.portal.core.portlet.test.FormAutoSubmitPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+ </supports>
+ <portlet-info>
+ <title>Auto submit</title>
+ <keywords>sample,test</keywords>
+ </portlet-info>
+ </portlet>
<user-attribute>
<name>user.name.nickName</name>
</user-attribute>