Author: wesleyhales
Date: 2008-02-13 00:05:58 -0500 (Wed, 13 Feb 2008)
New Revision: 9950
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/demo/demo3.jsp
modules/portlet/trunk/test/src/test/resources/simple-portal-war/demo/home.jsp
Log:
start of ajax portlet
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-12
23:24:48 UTC (rev 9949)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/portal/samples/basic/HeaderPortlet.java 2008-02-13
05:05:58 UTC (rev 9950)
@@ -45,25 +45,51 @@
ResourceURL resourceURL = resp.createResourceURL();
//
- Element elt = resp.createElement("script");
- elt.setAttribute("type", "text/javascript");
- elt.setAttribute("src", resourceURL.toString());
- elt.appendChild(elt.getOwnerDocument().createTextNode(""));
- resp.addProperty("script", elt);
+// Element elt = 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 = resp.getWriter();
- writer.print("<div
style=\"height:100px;width:100%;text-align:center;padding-top:50px;\"><a
href='javascript:" + resp.getNamespace() + "_handle()'>Click me to
trigger script</a></div>");
+ writer.print("" +
+ "<script type=\"text/javascript\">" +
+ "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;\">");
+// "<input type=\"text\" id=\"hidden-input\"
value=\"" + resourceURL.toString() + "\" />" +
+// "<a href='javascript:" + resp.getNamespace() +
"_handle()'>Click me to trigger script</a>" +
+ resourceURL.setParameter("prodId","1");
+ 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/>");
+
+ resourceURL.setParameter("prodId","3");
+ writer.print("<a href=\"javascript: browse(\'" +
resourceURL + "\')\">Product 3</a><br/>");
+
+ writer.print("</div>" +
+ "<br/>" +
+ "<div id=\"output-div\">Product
Details</div>");
}
public void serveResource(ResourceRequest req, ResourceResponse resp) throws
PortletException, IOException
{
String namespace =resp.getNamespace();
- resp.setContentType("text/javascript");
+ //resp.setContentType("application/json");
+ resp.setContentType("text/html");
PrintWriter writer = resp.getWriter();
- writer.print("function " + namespace + "_handle() { " +
- "new Effect.Grow(document.getElementById('header-portlet'))
}");
+
+ writer.print("<div>" + req.getParameter("prodId")
+"</div>");
+
writer.close();
}
}
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-12
23:24:48 UTC (rev 9949)
+++
modules/portlet/trunk/test/src/test/resources/simple-portal-war/demo/demo3.jsp 2008-02-13
05:05:58 UTC (rev 9950)
@@ -5,7 +5,7 @@
<%@ page isELIgnored="false" %>
<%@ include file="/layouts/header.jsp" %>
-
+
<portal:page>
<portal:pageparam namespaceURI="urn:jboss:portal:simple:google"
localName="zipcode" value="80201"/>
<jbp:layout1>
@@ -14,9 +14,11 @@
</jsp:attribute>
<jsp:attribute name="rightcol">
<jbp:portlet name="ExceptionPortlet"
applicationName="samples-basic"/>
+
<jbp:portlet name="HeaderPortlet"
applicationName="samples-basic" id="header-portlet"/>
+
</jsp:attribute>
+
</jbp:layout1>
</portal:page>
-
<%@ include file="/layouts/footer.jsp" %>
\ No newline at end of file
Modified: modules/portlet/trunk/test/src/test/resources/simple-portal-war/demo/home.jsp
===================================================================
---
modules/portlet/trunk/test/src/test/resources/simple-portal-war/demo/home.jsp 2008-02-12
23:24:48 UTC (rev 9949)
+++
modules/portlet/trunk/test/src/test/resources/simple-portal-war/demo/home.jsp 2008-02-13
05:05:58 UTC (rev 9950)
@@ -7,7 +7,14 @@
<%@ include file="/layouts/header.jsp" %>
<portal:page>
-
+ <jbp:layout1>
+ <jsp:attribute name="leftcol">
+
+ </jsp:attribute>
+ <jsp:attribute name="rightcol">
+
+ </jsp:attribute>
+ </jbp:layout1>
</portal:page>
<%@ include file="/layouts/footer.jsp" %>
\ No newline at end of file