Author: wesleyhales
Date: 2008-02-13 19:37:37 -0500 (Wed, 13 Feb 2008)
New Revision: 9958
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/portal/samples/basic/HeaderPortlet.java
modules/portlet/trunk/test/src/test/resources/simple-portal-war/css/master.css
modules/portlet/trunk/test/src/test/resources/simple-portal-war/demo/demo3.jsp
modules/portlet/trunk/test/src/test/resources/simple-portal-war/layouts/header.jsp
Log:
partial refresh portlet updates
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/portal/samples/basic/HeaderPortlet.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/portal/samples/basic/HeaderPortlet.java 2008-02-13
21:05:27 UTC (rev 9957)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/portal/samples/basic/HeaderPortlet.java 2008-02-14
00:37:37 UTC (rev 9958)
@@ -23,7 +23,10 @@
package org.jboss.portal.portlet.portal.samples.basic;
import org.w3c.dom.Element;
+import org.jboss.portal.portlet.ActionURL;
+import org.jboss.portal.portlet.RenderURL;
+
import javax.portlet.GenericPortlet;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
@@ -31,6 +34,14 @@
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;
import javax.portlet.ResourceURL;
+import javax.portlet.EventRequest;
+import javax.portlet.EventResponse;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletSecurityException;
+import javax.portlet.PortletURL;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletMode;
import java.io.IOException;
import java.io.PrintWriter;
@@ -40,11 +51,29 @@
*/
public class HeaderPortlet extends GenericPortlet
{
+ public final static int TITANIUM = 0;
+ public final static int PLATINUM = 1;
+ public final static int GOLD = 2;
+ public final static int SILVER = 3;
+ public final static int TIN = 4;
+
+ public void processAction(ActionRequest req, ActionResponse resp) throws
PortletException, PortletSecurityException, IOException
+ {
+
+ String repeatText = req.getParameter("repeat");
+ // set zip as render parameter
+ if (repeatText != null){
+ resp.setRenderParameter("repeat", repeatText);
+ }
+ // request view
+ resp.setPortletMode(PortletMode.VIEW);
+
+ }
public void render(RenderRequest req, RenderResponse resp) throws PortletException,
IOException
{
ResourceURL resourceURL = resp.createResourceURL();
-
- //
+ PortletURL actionURL = resp.createActionURL();
+ //
// Element elt = resp.createElement("script");
// elt.setAttribute("type", "text/javascript");
// elt.setAttribute("src", resourceURL.toString());
@@ -52,44 +81,109 @@
// resp.addProperty("script", elt);
//
+
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
writer.print("" +
"<script type=\"text/javascript\">" +
+ "" +
+ // "function init(){\n" +
+ //" Event.observe('repeat', 'keyup', repeat(),
false);\n" +
+ // "}" +
+ "" +
"function browse(id) {" +
"var url = id;\n" +
- "alert(url);\n" +
"var pars = 'foo=bar';\n" +
"var target = 'output-div';\n" +
"var myAjax = new Ajax.Updater(target, url, {method: 'GET',
parameters: pars});" +
"}" +
- "</script>" +
- "<div
style=\"height:100px;width:100%;text-align:center;padding-top:50px;\">");
+
+ "</script>");
+
+ writer.print("" +
+ "<div class='full-width'
style='padding:5px'>" +
+ "<h4>Partial Refresh Repeater Demo</h4>");
+ writer.print("" +
+ " <div class='half-width float-left'>" +
+ " <form method='post' id=\"testrepeatform\"
name=\"testrepeatform\" action=\"" + actionURL + "\"
onsubmit=\"new Ajax.Updater('repeat-div', '" + resourceURL +
"', {asynchronous:true, parameters:Form.serialize(this)}); return
false;\">\n" +
+ " <font class='portlet-font'>Repeat
Demo:</font><br/>\n" +
+ " <input class='portlet-form-input-field'
type='text' value='' size='12' name=\"repeat\"
id=\"repeat\" onkeyup=\"this.form.submit2.click();new
Effect.Highlight(document.getElementById('repeat-div'));\"/>\n" +
+ " <input class='portlet-form-input-field hidden'
type='submit' name='submit2' value='submit'
style=\"display:hidden;\">\n" +
+ " </form>\n" +
+ "</div>" +
+ "");
+ writer.print("<div id=\"repeat-div\" class='half-width
float-left'></div>");
// "<input type=\"text\" id=\"hidden-input\"
value=\"" + resourceURL.toString() + "\" />" +
// "<a href='javascript:" + resp.getNamespace() +
"_handle()'>Click me to trigger script</a>" +
+ writer.print("<br class='clear'/><br
class='clear'/><hr/>" +
+ "<h4>Partial Refresh Product Catalog</h4>" +
+ "<div class='full-width'>" +
+ "");
+ writer.print("<div class='float-left third-width'>");
resourceURL.setParameter("prodId","1");
- writer.print("<a href=\"javascript: browse(\'" +
resourceURL + "\')\">Product 1</a><br/>");
+ writer.print("<a href=\"javascript: browse(\'" +
resourceURL + "\');\">Product 1</a><br/>");
resourceURL.setParameter("prodId","2");
- writer.print("<a href=\"javascript: browse(\'" +
resourceURL + "\')\">Product 2</a><br/>");
+ writer.print("<a href=\"javascript: browse(\'" +
resourceURL + "\');\">Product 2</a><br/>");
resourceURL.setParameter("prodId","3");
- writer.print("<a href=\"javascript: browse(\'" +
resourceURL + "\')\">Product 3</a><br/>");
+ writer.print("<a href=\"javascript: browse(\'" +
resourceURL + "\');\">Product 3</a><br/>");
- writer.print("</div>" +
- "<br/>" +
- "<div id=\"output-div\">Product
Details</div>");
+ writer.print("<br class='clear'/></div>");
+ writer.print("<div class='float-left two-third-width'>"
+
+ "<h4 class='zero'>Product Details</h4>" +
+ "<div id=\"output-div\"></div>" +
+ "");
+ writer.print("<br class='clear'/></div>");
+ writer.print("<br class='clear'/></div>");
+ writer.print("<br class='clear'/></div>");
+
+
+
+ // writer.print("</div>");
}
public void serveResource(ResourceRequest req, ResourceResponse resp) throws
PortletException, IOException
{
+ String repeatText = req.getParameter("repeat");
+ String prodId = req.getParameter("prodId");
+
String namespace =resp.getNamespace();
//resp.setContentType("application/json");
resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
+ if (repeatText != null){
+ writer.print("<div id=\"repeat-text\">"+
req.getPrivateParameterMap().get("repeat")[0] +"</div>");
+ }
+ if (prodId != null){
+ if (prodId.equals("1")){
+ writer.print("<div id=\"product-text\">Product ID:
"+ prodId +"" +
+ "<br/>" +
+ " B BY BURTON ALPHA<br/>" +
+ "Sale Price: $314.96 " +
+ "</div>");
+ }
+ if (prodId.equals("2")){
+ writer.print("<div id=\"product-text\">Product ID:
"+ prodId +"" +
+ "<br/>" +
+ "FORUM DESTROYER LTD<br/>" +
+ "$319.99 " +
+ "</div>");
+ }
+ if (prodId.equals("3")){
+ writer.print("<div id=\"product-text\">Product ID:
"+ prodId +"" +
+ "<br/>" +
+ "\n" +
+ "SANTA CRUZ ALLSTAR<br/>" +
+ "$256.00 " +
+ "</div>");
+ }
- writer.print("<div>" + req.getParameter("prodId")
+"</div>");
+ }
+
+
+
writer.close();
}
}
Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/css/master.css
===================================================================
---
modules/portlet/trunk/test/src/test/resources/simple-portal-war/css/master.css 2008-02-13
21:05:27 UTC (rev 9957)
+++
modules/portlet/trunk/test/src/test/resources/simple-portal-war/css/master.css 2008-02-14
00:37:37 UTC (rev 9958)
@@ -1,4 +1,5 @@
-body {
+body,
+div.container {
font: normal 12px Lucida Sans, Trebuchet, tahoma, sans-serif;
}
@@ -81,6 +82,12 @@
border: 0;
}
+.zero {
+ margin: 0;
+ padding: 0;
+ border: 0;
+}
+
body,
div,
form,
Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/demo/demo3.jsp
===================================================================
---
modules/portlet/trunk/test/src/test/resources/simple-portal-war/demo/demo3.jsp 2008-02-13
21:05:27 UTC (rev 9957)
+++
modules/portlet/trunk/test/src/test/resources/simple-portal-war/demo/demo3.jsp 2008-02-14
00:37:37 UTC (rev 9958)
@@ -8,6 +8,7 @@
<portal:page>
<portal:pageparam namespaceURI="urn:jboss:portal:simple:google"
localName="zipcode" value="80201"/>
+
<jbp:layout1>
<jsp:attribute name="leftcol">
<jbp:portlet name="Foo" applicationName="bar"/>
Modified:
modules/portlet/trunk/test/src/test/resources/simple-portal-war/layouts/header.jsp
===================================================================
---
modules/portlet/trunk/test/src/test/resources/simple-portal-war/layouts/header.jsp 2008-02-13
21:05:27 UTC (rev 9957)
+++
modules/portlet/trunk/test/src/test/resources/simple-portal-war/layouts/header.jsp 2008-02-14
00:37:37 UTC (rev 9958)
@@ -3,7 +3,7 @@
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html
xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en">
+<html
xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en" id="testreplace">
<head>
<title>Portlet Container 2.0</title>
<link rel="stylesheet"
href="${pageContext.request.contextPath}/css/master.css"
type="text/css"/>