Author: chris.laprun(a)jboss.com
Date: 2009-03-04 11:37:26 -0500 (Wed, 04 Mar 2009)
New Revision: 12942
Modified:
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/PortletSessionPortlet.java
Log:
- JBPORTAL-2329: Fixed the portlet so that it works in an AJAX context... We need a
workaround for the way Form.serialize
works in Prototype when a form has multiple submit inputs.
See
http://groups.google.com/group/prototype-core/browse_thread/thread/b3ced6...
for more details.
Modified:
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/PortletSessionPortlet.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/PortletSessionPortlet.java 2009-03-04
15:42:59 UTC (rev 12941)
+++
branches/JBoss_Portal_Branch_2_7/core-samples/src/main/org/jboss/portal/core/samples/basic/PortletSessionPortlet.java 2009-03-04
16:37:26 UTC (rev 12942)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, 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. *
@@ -44,7 +44,8 @@
{
String name = req.getParameter("name");
String value = req.getParameter("value");
- boolean portletScope = req.getParameter("portlet") != null;
+ String scope = req.getParameter("scope");
+ boolean portletScope = "portlet".equals(scope);
if (name != null && value != null)
{
req.getPortletSession().setAttribute(name, value, portletScope ?
PortletSession.PORTLET_SCOPE : PortletSession.APPLICATION_SCOPE);
@@ -85,11 +86,19 @@
}
//
- writer.println("<form action=\"" + purl.toString() +
"\" method=\"post\">");
+ writer.println("<script type='text/javascript'>\n" +
+ "function processForm(value) {" +
+ "var form = document.getElementById('sessionForm');\n" +
+ "var hidden = document.getElementById('sessionHidden');\n" +
+ "hidden.value = value;\n" +
+ "form.submit();}\n" +
+ "</script>");
+ writer.println("<form id='sessionForm' action=\"" +
purl.toString() + "\" method=\"post\">");
writer.println("<input type=\"text\"
name=\"name\"/>");
writer.println("<input type=\"text\"
name=\"value\"/>");
- writer.println("<input type=\"submit\" name=\"portlet\"
value=\"Add to portlet scope\"/>");
- writer.println("<input type=\"submit\"
name=\"application\" value=\"Add to application scope\"/>");
+ writer.println("<input type=\"button\" name=\"portlet\"
value=\"Add to portlet scope\"
onclick=\"processForm('portlet')\"/>");
+ writer.println("<input type=\"button\"
name=\"application\" value=\"Add to application scope\"
onclick=\"processForm('application')\"/>");
+ writer.println("<input id='sessionHidden' name='scope'
type='hidden'/>");
writer.println("</form><br/>");
//