portals-pluto-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msnickl...@apache.org
Subject [2/5] portals-pluto git commit: Restructured the demo portlets to move markup & JavaScript code into JSP files in order to make it more 'presentable'. Ran the portlet JavaScript through jslint to remove errors and improve style.
Date Sat, 29 Nov 2014 18:47:57 GMT
Restructured the demo portlets to move markup &  JavaScript code into JSP
files in order to make it more 'presentable'. Ran the portlet JavaScript
through jslint to remove errors and improve style.


Project: http://git-wip-us.apache.org/repos/asf/portals-pluto/repo
Commit: http://git-wip-us.apache.org/repos/asf/portals-pluto/commit/d4269e94
Tree: http://git-wip-us.apache.org/repos/asf/portals-pluto/tree/d4269e94
Diff: http://git-wip-us.apache.org/repos/asf/portals-pluto/diff/d4269e94

Branch: refs/heads/PortletHub
Commit: d4269e9460dc10a5c74a3495416c3388e6d04ac3
Parents: 27c71e2
Author: Scott Nicklous <msnicklous@apache.org>
Authored: Wed Nov 26 14:00:40 2014 +0100
Committer: Scott Nicklous <msnicklous@apache.org>
Committed: Wed Nov 26 14:00:40 2014 +0100

----------------------------------------------------------------------
 PortletHubDemo/pom.xml                          |   5 +-
 .../java/basic/portlet/ColorSelPortlet.java     | 121 +-------------
 .../java/basic/portlet/ImageSelPortlet.java     | 139 +----------------
 .../java/basic/portlet/MessageBoxPortlet.java   |  62 +-------
 .../java/basic/portlet/ResourcePortlet.java     |  98 +-----------
 .../src/main/webapp/WEB-INF/jsp/view-csp.jsp    | 150 ++++++++++++++++++
 .../src/main/webapp/WEB-INF/jsp/view-isp.jsp    | 156 +++++++++++++++++++
 .../src/main/webapp/WEB-INF/jsp/view-ivp.jsp    | 125 +++++++++++++++
 .../src/main/webapp/WEB-INF/jsp/view-mbp.jsp    |  89 +++++++++++
 .../src/main/webapp/WEB-INF/jsp/view.jsp        |  27 ----
 10 files changed, 542 insertions(+), 430 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/d4269e94/PortletHubDemo/pom.xml
----------------------------------------------------------------------
diff --git a/PortletHubDemo/pom.xml b/PortletHubDemo/pom.xml
index 89b5286..8ab229d 100644
--- a/PortletHubDemo/pom.xml
+++ b/PortletHubDemo/pom.xml
@@ -76,7 +76,7 @@
                 <dependency>
                     <groupId>javax.servlet</groupId>
                     <artifactId>jstl</artifactId>
-                    <scope>provided</scope>
+                    <scope>compile</scope>
                     <exclusions>
                         <exclusion>
                             <groupId>javax.servlet</groupId>
@@ -87,7 +87,7 @@
                 <dependency>
                     <groupId>taglibs</groupId>
                     <artifactId>standard</artifactId>
-                    <scope>provided</scope>
+                    <scope>compile</scope>
                 </dependency>
          </dependencies>
          
@@ -104,7 +104,6 @@
                <plugin>
                   <groupId>org.apache.portals.pluto</groupId>
                   <artifactId>maven-pluto-plugin</artifactId>
-                  <version>${project.version}</version>
                   <dependencies>
                      <dependency>
                         <groupId>org.apache.portals.pluto</groupId>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/d4269e94/PortletHubDemo/src/main/java/basic/portlet/ColorSelPortlet.java
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/java/basic/portlet/ColorSelPortlet.java b/PortletHubDemo/src/main/java/basic/portlet/ColorSelPortlet.java
index 903ce9d..fed79e6 100644
--- a/PortletHubDemo/src/main/java/basic/portlet/ColorSelPortlet.java
+++ b/PortletHubDemo/src/main/java/basic/portlet/ColorSelPortlet.java
@@ -27,6 +27,7 @@ import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
 import javax.portlet.GenericPortlet;
 import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
 import javax.portlet.PortletURL;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
@@ -49,123 +50,11 @@ public class ColorSelPortlet extends GenericPortlet {
 
       
       resp.setContentType("text/html");
-      PrintWriter writer = resp.getWriter();
-      writer.write("<h3>Color Selector & Message Sender</h3><hr/>\n");
-      
-      String pid = resp.getNamespace();
-      
-      String clr = req.getParameter(PARAM_COLOR);
-      clr = (clr == null) ? "#FFFFFF" : clr;
-      
-      String[] vals = req.getParameterValues(PARAM_FG_COLOR);
-      String r = "";
-      String g = "";
-      String b = "";
-      if (vals != null) {
-         for (String v : vals) {
-            if (v.equals(PARAM_FG_RED)) r = "checked";
-            if (v.equals(PARAM_FG_GREEN)) g = "checked";
-            if (v.equals(PARAM_FG_BLUE)) b = "checked";
-         }
-      }
-      
-      writer.write("<FORM id='" + pid + "-setParams'  onsubmit='return false;'>");
-      writer.write("   <table><tr><td align='left'>\n");
 
-      writer.write("   Enter background color (public param):\n");
-      writer.write("   </td><td colspan=3>\n");
-      writer.write("   <input id='" + pid + "-color' name='" + PARAM_COLOR + "' type='text' value='" + clr + "' size='10' maxlength='10'>\n");
-      writer.write("   </td><td><div id='" + pid + "-putMsgHere'>\n");
-      writer.write("   </div></td></tr><tr><td>\n");
-
-      writer.write("   Select active foreground colors:\n");
-      writer.write("   </td><td>\n");
-      writer.write("   <input id='" + pid + "-red' name='" + PARAM_FG_COLOR + "' value='" + PARAM_FG_RED + "' type='checkbox' " + r + ">\n");
-      writer.write("   </td><td>Red\n");
-      writer.write("   </td><td>\n");
-      writer.write("   <input id='" + pid + "-green'  name='" + PARAM_FG_COLOR + "' value='" + PARAM_FG_GREEN + "' type='checkbox' " + g + ">\n");
-      writer.write("   </td><td>Green\n");
-      writer.write("   </td><td>\n");
-      writer.write("   <input id='" + pid + "-blue'  name='" + PARAM_FG_COLOR + "' value='" + PARAM_FG_BLUE + "' type='checkbox' " + b + ">\n");
-      writer.write("   </td><td>Blue\n");
-
-      writer.write("   </td></tr><tr><td>\n");
-      writer.write("   Enter message:\n");
-      writer.write("   </td><td colspan=6>\n");
-      writer.write("   <input id='" + pid + "-msg' name='" + PARAM_MSG_INPUT + "' type='text' value='' size='50' maxlength='50'>\n");
-      writer.write("   </td><td>\n");
-
-      writer.write("   </td></tr><tr><td>\n");
-      writer.write("   <INPUT id ='" + pid + "-send' VALUE='send' TYPE='button'>\n");
-      writer.write("   </td></tr></table>\n");
-      writer.write("</FORM>\n");
-      writer.write("<p><hr/></p>\n");
-
-      writer.write("<script>\n");
-      writer.write("(function () {\n");
-      writer.write("   var pid = '" + pid + "',\n");
-      writer.write("       colorEntry = '" + pid + "-color',\n");
-      writer.write("       msgdiv = '" + pid + "-putMsgHere',\n");
-      writer.write("       sendbtn = '" + pid + "-send',\n");
-      writer.write("       rid = '" + pid + "-red',\n");
-      writer.write("       gid = '" + pid + "-green',\n");
-      writer.write("       bid = '" + pid + "-blue',\n");
-      writer.write("       mid = '" + pid + "-msg',\n");
-      writer.write("       currState,\n");
-      writer.write("       portletInit;\n");
-
-      writer.write("   var update = function (type, state) {\n");
-      writer.write("      var oldColor = ((currState === undefined) || (currState.parameters.color === undefined)) ? '#FFFFFF' : currState.parameters.color[0];\n");
-      writer.write("      var newColor = (state.parameters.color === undefined) ? '#FFFFFF' : state.parameters.color[0];\n");
-      writer.write("      console.log(\"CSP: state updated. color=\" + newColor);\n");
-      writer.write("      if ((currState === undefined) || (newColor !== oldColor)) {\n");
-      writer.write("         document.getElementById(msgdiv).innerHTML = '';\n");
-      writer.write("         document.getElementById(colorEntry).value = newColor;\n");
-      writer.write("      }\n");
-      writer.write("      currState = state;\n");
-      writer.write("   }\n");
-      writer.write("   \n");
-
-      writer.write("   var handleEntry = function () {\n");
-      writer.write("      var oldColor = ((currState === undefined) || (currState.parameters.color === undefined)) ? '#FFFFFF' : currState.parameters.color[0];\n");
-      writer.write("      var newColor = this.value;\n");
-      writer.write("      console.log(\"CSP: entry field updated. color=\" + newColor);\n");
-      writer.write("      if ((newColor === undefined) || (newColor === null) || !newColor.match(\"^#(?:[A-Fa-f0-9]{3}){1,2}$\")) {\n");
-      writer.write("         document.getElementById(msgdiv).innerHTML = 'Bad color. Enter #xxxxxx or #xxx.';\n");
-      writer.write("      } else {\n");
-      writer.write("         var newState = portletInit.cloneState(currState);\n");
-      writer.write("         newState.parameters.color = [newColor];\n");
-      writer.write("         portletInit.setPortletState(newState);\n");
-      writer.write("      }\n");
-      writer.write("   }\n");
-      writer.write("   document.getElementById(colorEntry).onchange = handleEntry;\n");
-      writer.write("   \n");
-
-      writer.write("   var handleSend = function () {\n");
-      writer.write("      var parms = {}, clrs = [], msg = \"\";\n");
-      writer.write("      console.log(\"CSP: sending message.\");");
-      writer.write("      parms['action'] = ['send'];\n");
-      writer.write("      if (document.getElementById(rid).checked) clrs.push(\"red\"); \n");
-      writer.write("      if (document.getElementById(gid).checked) clrs.push(\"green\"); \n");
-      writer.write("      if (document.getElementById(bid).checked) clrs.push(\"blue\"); \n");
-      writer.write("      if (clrs.length > 0) {\n");
-      writer.write("         parms['fgcolor'] = clrs;\n");
-      writer.write("      }\n");
-      writer.write("      parms['imsg'] = [document.getElementById(mid).value];\n");
-      writer.write("      portletInit.action(parms);\n");
-      writer.write("   }\n");
-      writer.write("   document.getElementById(sendbtn).onclick = handleSend;\n");
-      writer.write("   \n");
-
-      writer.write("   portlet.register(pid).then(function (pi) {\n");
-      writer.write("      console.log(\"CSP Color Selection Portlet: registered: \" + pid);\n");
-      writer.write("      portletInit = pi;\n");
-      writer.write("      portletInit.addEventListener(\"portlet.onStateChange\", update);\n");
-      writer.write("   });\n");
-      writer.write("   \n");
-      writer.write("   \n");
-      writer.write("})();\n");
-      writer.write("</script>\n");
+      PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(
+            "/WEB-INF/jsp/view-csp.jsp");
+         rd.include(req, resp);
+      
 }
    
    /* (non-Javadoc)

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/d4269e94/PortletHubDemo/src/main/java/basic/portlet/ImageSelPortlet.java
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/java/basic/portlet/ImageSelPortlet.java b/PortletHubDemo/src/main/java/basic/portlet/ImageSelPortlet.java
index 4ed5c7b..4475ebb 100644
--- a/PortletHubDemo/src/main/java/basic/portlet/ImageSelPortlet.java
+++ b/PortletHubDemo/src/main/java/basic/portlet/ImageSelPortlet.java
@@ -22,6 +22,7 @@ import static basic.portlet.Constants.PARAM_IMGNAME;
 import static basic.portlet.Constants.PARAM_SELTYPE;
 import static basic.portlet.Constants.PARAM_SELTYPE_RADIO;
 import static basic.portlet.Constants.imgMap;
+
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.Set;
@@ -32,6 +33,7 @@ import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
 import javax.portlet.GenericPortlet;
 import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.ResourceRequest;
@@ -55,141 +57,10 @@ public class ImageSelPortlet extends GenericPortlet {
       }
       
       resp.setContentType("text/html");
-      PrintWriter writer = resp.getWriter();
-      writer.write("<h3>Image Selector</h3><hr/>\n");
-      
-      String pid = resp.getNamespace();
-      String selType = req.getParameter(PARAM_SELTYPE);
-      selType = (selType == null) ? PARAM_SELTYPE_RADIO : selType;
-      String imgName = req.getParameter(PARAM_IMGNAME);
-      imgName = (imgName == null) ? "default" : imgName;
-      
-      writer.write("<FORM id='" + pid + "-setParams' onsubmit='return false;'>");
-      writer.write("   <table><tr><td align='left'>");
-      writer.write("   Selection type (private param):");
-      writer.write("   </td><td>");
-      writer.write("   <input id='" + pid + "-radio' type='radio' name='selType' value='radio'>Radio Button");
-      writer.write("   <input id='" + pid + "-dropdown' type='radio' name='selType' value='dropdown'>Drop Down");
-      writer.write("   </td></tr><tr><td>");
-      writer.write("   Select Image (public param):");
-      writer.write("   </td><td>");
-
-      writer.write("   <div id='" + pid + "-putResourceHere'></div>\n");
-
-      writer.write("   </td></tr></table>");
-      writer.write("</FORM>");
-      writer.write("<p><hr/></p>\n");
-
-      writer.write("<script>\n");
-      writer.write("(function () {\n");
-      writer.write("   var pid = '" + pid + "',\n");
-      writer.write("       fid = '" + pid + "-setParams',\n");
-      writer.write("       resdiv = '" + pid + "-putResourceHere',\n");
-      writer.write("       st_radio = '" + pid + "-radio',\n");
-      writer.write("       st_dropdown = '" + pid + "-dropdown',\n");
-      writer.write("       selBox = '" + pid + "-selBox',\n");
-      writer.write("   \n");
-      writer.write("       last_st = 'radio',\n");
-      writer.write("       lastImg = 'default',\n");
-      writer.write("       currState,\n");
-      writer.write("       portletInit;\n");
-      writer.write("   \n");
-      writer.write("   // Set image name PRP if radio button clicked - \n");
-      writer.write("   var handleImgRadio = function () {\n");
-      writer.write("      console.log(\"ISP: image selected (radio): \" + this.value);\n");
-      writer.write("      \n");
-      writer.write("      if (currState.parameters.imgName !== this.value) {\n");
-      writer.write("         var newState = portletInit.cloneState(currState);\n");
-      writer.write("         newState.parameters.imgName = [this.value];\n");
-      writer.write("         portletInit.setPortletState(newState);\n");
-      writer.write("      }\n");
-      writer.write("   }\n");
-      writer.write("   \n");
-      writer.write("   // Set image name PRP if image selected in selection box - \n");
-      writer.write("   var handleImgDropdown = function () {\n");
-      writer.write("      console.log(\"ISP: image selected (dropdown): \" + this.value);\n");
-      writer.write("      \n");
-      writer.write("      if (currState.parameters.imgName !== this.value) {\n");
-      writer.write("         var newState = portletInit.cloneState(currState);\n");
-      writer.write("         newState.parameters.imgName = [this.value];\n");
-      writer.write("         portletInit.setPortletState(newState);\n");
-      writer.write("      }\n");
-      writer.write("   }\n");
-      writer.write("   \n");
-      writer.write("   var update = function (type, state) {\n");
-      writer.write("      var oldST = ((currState === undefined) || (currState.parameters.selType === undefined)) ? undefined : currState.parameters.selType[0];\n");
-      writer.write("      var newST = (state.parameters.selType === undefined) ? undefined : state.parameters.selType[0];\n");
-      writer.write("      var newImg = (state.parameters.imgName === undefined) ? undefined : state.parameters.imgName[0];\n");
-      writer.write("      console.log(\"ISP: state updated. selType=\" + newST + \", imgName=\" + newImg);\n");
-      writer.write("      \n");
-      writer.write("      if ((currState === undefined) || (oldST !== newST)) {");
-      writer.write("         portletInit.createResourceUrl({}).then(function (url) {\n");
-      writer.write("            console.log(\"ISP: got url: \" + url);\n");
-//      writer.write("            document.getElementById(resdiv).innerHTML=\"Waiting for update.\";\n");
-      writer.write("            var xhr = new XMLHttpRequest();\n");
-      writer.write("            xhr.onreadystatechange=function() {\n");
-      writer.write("               if (xhr.readyState==4 && xhr.status==200) {\n");
-      writer.write("                  document.getElementById(resdiv).innerHTML=xhr.responseText;\n");
-
-      writer.write("                  // default is radio buttons\n");
-      writer.write("                  var ii, f = document.getElementById(fid);\n");
-      writer.write("                  if ((newST === undefined) || (newST === 'radio')) {\n");
-      writer.write("                     for (ii=0; ii < f.imgName.length; ii++) {\n");
-      writer.write("                        console.log(\"ISP: adding selection handler for: \" + f.imgName[ii].value);\n");
-      writer.write("                        f.imgName[ii].onclick = handleImgRadio;\n");
-      writer.write("                        if (f.imgName[ii].value === newImg) {\n");
-      writer.write("                           console.log(\"ISP: image clicked: \" + newImg);\n");
-      writer.write("                           f.imgName[ii].clicked = true;\n");
-      writer.write("                        }\n");
-      writer.write("                     }\n");
-      writer.write("                  } else if (newST === 'dropdown') {\n");
-      writer.write("                     console.log(\"ISP: adding selection handler to dropdown list element: \" + selBox);\n");
-      writer.write("                     document.getElementById(selBox).onchange = handleImgDropdown;\n");
-      writer.write("                     for (ii=0; ii < f.imgName.length; ii++) {\n");
-      writer.write("                        if (f.imgName[ii].value === newImg) {\n");
-      writer.write("                           console.log(\"ISP: image selected: \" + newImg);\n");
-      writer.write("                           f.imgName[ii].selected = true;\n");
-      writer.write("                        }\n");
-      writer.write("                     }\n");
-      writer.write("                  }\n");
-
-      writer.write("               }\n");
-      writer.write("            };\n");
-      writer.write("            xhr.open(\"GET\",url,true);\n");
-      writer.write("            xhr.send();\n");
-      writer.write("         });\n");
-      writer.write("      }\n");
-
-      writer.write("      if (newST === 'dropdown') {\n");
-      writer.write("         document.getElementById(st_dropdown).checked = true;\n");
-      writer.write("      } else {\n");
-      writer.write("         document.getElementById(st_radio).checked = true;\n");
-      writer.write("      }\n");
 
-      writer.write("      currState=state;\n");
-      writer.write("   }\n");
-      writer.write("   \n");
-      writer.write("   // set private parameter selType to store the selection display type\n");
-      writer.write("   var handleST = function () {\n");
-      writer.write("      console.log(\"ISP: select display type clicked: \" + this.value);\n");
-      writer.write("      if (currState.parameters.selType !==  this.value) {\n");
-      writer.write("         var newState = portletInit.cloneState(currState);\n");
-      writer.write("         newState.parameters.selType = [this.value];\n");
-      writer.write("         portletInit.setPortletState(newState);\n");
-      writer.write("      }\n");
-      writer.write("   }\n");
-      writer.write("   document.getElementById(st_radio).onclick = handleST;\n");
-      writer.write("   document.getElementById(st_dropdown).onclick = handleST;\n");
-      writer.write("   \n");
-      writer.write("   portlet.register(pid).then(function (pi) {\n");
-      writer.write("      console.log(\"ISP Image Selection Portlet: registered: \" + pid);\n");
-      writer.write("      portletInit = pi;\n");
-      writer.write("      portletInit.addEventListener(\"portlet.onStateChange\", update);\n");
-      writer.write("   });\n");
-      writer.write("   \n");
-      writer.write("   \n");
-      writer.write("})();\n");
-      writer.write("</script>\n");
+      PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(
+            "/WEB-INF/jsp/view-isp.jsp");
+      rd.include(req, resp);
 
    }
    

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/d4269e94/PortletHubDemo/src/main/java/basic/portlet/MessageBoxPortlet.java
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/java/basic/portlet/MessageBoxPortlet.java b/PortletHubDemo/src/main/java/basic/portlet/MessageBoxPortlet.java
index 8f8e648..232b696 100644
--- a/PortletHubDemo/src/main/java/basic/portlet/MessageBoxPortlet.java
+++ b/PortletHubDemo/src/main/java/basic/portlet/MessageBoxPortlet.java
@@ -33,6 +33,7 @@ import javax.portlet.EventResponse;
 import javax.portlet.GenericPortlet;
 import javax.portlet.PortletContext;
 import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.ResourceRequest;
@@ -55,64 +56,11 @@ public class MessageBoxPortlet extends GenericPortlet {
          logger.logp(Level.FINE, this.getClass().getName(), "doView", "Entry");
       }
       
-      String pid = resp.getNamespace();
       resp.setContentType("text/html");
-      PrintWriter writer = resp.getWriter();
-      String style = "\"border-style:solid; border-width:3px; padding:4px; overflow:auto;" + 
-           "border-color:#000088; min-height:70px; background:#E0E0E0;\"";
-      
-      writer.write("<div style='clear:both;'>\n");
-      writer.write("<div style='float:left;'><h3>Image Viewer</h3></div>\n");
-      writer.write("<div style='float:right;'>\n");
-      writer.write("<form   onsubmit='return false;'><input id='" + pid + "-clear' type='submit' name='action' value='clear' /></form>\n");
-      writer.write("</div>\n");
-      writer.write("</div><div style='clear:both;'><hr/>\n");
-      writer.write("<h3>Message Box Portlet</h3>\n");
-      writer.write("<p>Messages that arrive via events from other portlets are displayed in this box.</p>\n");
-      writer.write("<div id='" + pid + "-responseDiv' style=" + style + "></div>\n");
-      writer.write("</div>\n");
-   
-      writer.write("<script>\n");
-      writer.write("(function () {\n");
-      writer.write("   var pid = '" + pid + "',\n");
-      writer.write("       resdiv = '" + pid + "-responseDiv',\n");
-      writer.write("       clrButton = '" + pid + "-clear',\n");
-      writer.write("   \n");
-      writer.write("       state,\n");
-      writer.write("       resparms = {},\n");
-      writer.write("       cacheability = 'cacheLevelPage',\n");
-      writer.write("       portletInit;\n");
-      writer.write("   \n");
-      writer.write("   var update = function (type, state) {\n");
-      writer.write("      console.log(\"Resource Portlet: state updated.\");\n");
-      writer.write("      \n");
-      writer.write("      portletInit.createResourceUrl(resparms, cacheability).then(function (url) {\n");
-      writer.write("         var brdr = (resparms.border == undefined) ? undefined : resparms.border[0];\n");
-      writer.write("         console.log(\"Resource Portlet: got url: \" + url + \", res parm border=\" + brdr);\n");
-      writer.write("         var xhr = new XMLHttpRequest();\n");
-      writer.write("         xhr.onreadystatechange=function() {\n");
-      writer.write("            if (xhr.readyState==4 && xhr.status==200) {\n");
-      writer.write("               document.getElementById(resdiv).innerHTML=xhr.responseText;\n");
-      writer.write("            }\n");
-      writer.write("         };\n");
-      writer.write("         xhr.open(\"GET\",url,true);\n");
-      writer.write("         xhr.send();\n");
-      writer.write("      });\n");
-      writer.write("   }\n");
-      writer.write("   \n");
-      writer.write("   document.getElementById(clrButton).onclick = function () {\n");
-      writer.write("      console.log(\"clear button clicked. \");\n");
-      writer.write("      portletInit.action();\n");
-      writer.write("   }\n");
-      writer.write("   \n");
-      writer.write("   portlet.register(pid).then(function (pi) {\n");
-      writer.write("      console.log(\"Message Box portlet registered: \" + pid);\n");
-      writer.write("      portletInit = pi;\n");
-      writer.write("      portletInit.addEventListener(\"portlet.onStateChange\", update);\n");
-      writer.write("   });\n");
-      writer.write("   \n");
-      writer.write("})();\n");
-      writer.write("</script>\n");
+
+      PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(
+            "/WEB-INF/jsp/view-mbp.jsp");
+      rd.include(req, resp);
 
    }
 

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/d4269e94/PortletHubDemo/src/main/java/basic/portlet/ResourcePortlet.java
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/java/basic/portlet/ResourcePortlet.java b/PortletHubDemo/src/main/java/basic/portlet/ResourcePortlet.java
index e9bcf63..ea0d918 100644
--- a/PortletHubDemo/src/main/java/basic/portlet/ResourcePortlet.java
+++ b/PortletHubDemo/src/main/java/basic/portlet/ResourcePortlet.java
@@ -23,6 +23,7 @@ import static basic.portlet.Constants.PARAM_COLOR;
 import static basic.portlet.Constants.PARAM_IMGNAME;
 import static basic.portlet.Constants.imgMap;
 import static basic.portlet.Constants.DEFAULT_IMAGE;
+
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.logging.Level;
@@ -32,6 +33,7 @@ import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
 import javax.portlet.GenericPortlet;
 import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.ResourceRequest;
@@ -56,101 +58,11 @@ public class ResourcePortlet extends GenericPortlet {
       }
       
       resp.setContentType("text/html");
-      PrintWriter writer = resp.getWriter();
 
-      String pid = resp.getNamespace();
+      PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(
+         "/WEB-INF/jsp/view-ivp.jsp");
+      rd.include(req, resp);
 
-      writer.write("<div style='clear:both;'>\n");
-      writer.write("<div style='float:left;'><h3>Image Viewer</h3></div>\n");
-      writer.write("<div id=" + pid + "-counter style='float:right; font-size:250%; color:#0B0;'>1</div>\n");
-      writer.write("</div><div style='clear:both;'><hr/>\n");
-      
-      writer.write("<FORM id='" + pid + "-setParams'  onsubmit='return false;'>");
-      writer.write("   <table><tr><td align='left'>");
-      writer.write("   Cacheability setting:");
-      writer.write("   </td><td>");
-      writer.write("   <input id='" + pid + "-page' type='radio' name='cacheability' value='cacheLevelPage'>Page");
-      writer.write("   <input id='" + pid + "-portlet' type='radio' name='cacheability' value='cacheLevelPortlet'>Portlet");
-      writer.write("   <input id='" + pid + "-full' type='radio' name='cacheability' value='cacheLevelFull'>Full");
-      writer.write("   </td></tr><tr><td>");
-      writer.write("   Set border (resource parameter)");
-      writer.write("   </td><td>");
-      writer.write("   <input id='" + pid + "-border' type='checkbox' name='border' value='border'>");
-      writer.write("   </td></tr></table>");
-      writer.write("</FORM><hr/>");
-
-      writer.write("<div id='" + pid + "-putResourceHere'></div>\n");
-      
-      writer.write("<script>\n");
-      writer.write("(function () {\n");
-      writer.write("   var pid = '" + pid + "',\n");
-      writer.write("       resdiv = '" + pid + "-putResourceHere',\n");
-      writer.write("       border = '" + pid + "-border',\n");
-      writer.write("       ca_page = '" + pid + "-page',\n");
-      writer.write("       ca_portlet = '" + pid + "-portlet',\n");
-      writer.write("       ca_full = '" + pid + "-full',\n");
-      writer.write("   \n");
-      writer.write("       state,\n");
-      writer.write("       resparms = {},\n");
-      writer.write("       cacheability = 'cacheLevelPage',\n");
-      writer.write("       portletInit;\n");
-      writer.write("   \n");
-      writer.write("   var update = function (type, state) {\n");
-      writer.write("      console.log(\"Resource Portlet: state updated.\");\n");
-      writer.write("      \n");
-      writer.write("      portletInit.createResourceUrl(resparms, cacheability).then(function (url) {\n");
-      writer.write("         var brdr = (resparms.border == undefined) ? undefined : resparms.border[0];\n");
-      writer.write("         console.log(\"Resource Portlet: got url: \" + url + \", res parm border=\" + brdr);\n");
-//      writer.write("         document.getElementById(resdiv).innerHTML=\"Waiting for update.\";\n");
-      writer.write("         var xhr = new XMLHttpRequest();\n");
-      writer.write("         xhr.onreadystatechange=function() {\n");
-      writer.write("            if (xhr.readyState==4 && xhr.status==200) {\n");
-      writer.write("               document.getElementById(resdiv).innerHTML=xhr.responseText;\n");
-      writer.write("            }\n");
-      writer.write("         };\n");
-      writer.write("         xhr.open(\"GET\",url,true);\n");
-      writer.write("         xhr.send();\n");
-      writer.write("      });\n");
-      writer.write("   }\n");
-      writer.write("   \n");
-      writer.write("   document.getElementById(border).checked = false;\n");
-      writer.write("   document.getElementById(border).onclick = function () {\n");
-      writer.write("      console.log(\"border checked: \" + this.checked);\n");
-      writer.write("      if (this.checked) {\n");
-      writer.write("         resparms.border = ['#00F'];\n");
-      writer.write("      } else {\n");
-      writer.write("         resparms = {};\n");
-      writer.write("      }\n");
-      writer.write("      update();\n");
-      writer.write("   }\n");
-      writer.write("   \n");
-      writer.write("   document.getElementById(ca_page).checked = true;\n");
-      writer.write("   var handleCA = function () {\n");
-      writer.write("      console.log(\"cacheability button clicked: \" + this.value);\n");
-      writer.write("      if (cacheability !== this.value) {\n");
-      writer.write("         cacheability = this.value;\n");
-      writer.write("         update();\n");
-      writer.write("      }\n");
-      writer.write("   }\n");
-      writer.write("   document.getElementById(ca_page).onclick = handleCA;\n");
-      writer.write("   document.getElementById(ca_portlet).onclick = handleCA;\n");
-      writer.write("   document.getElementById(ca_full).onclick = handleCA;\n");
-      writer.write("   \n");
-      writer.write("   portlet.register(pid).then(function (pi) {\n");
-      writer.write("      console.log(\"registered: \" + pid);\n");
-      writer.write("      portletInit = pi;\n");
-      writer.write("      portletInit.addEventListener(\"portlet.onStateChange\", update);\n");
-      writer.write("   });\n");
-      writer.write("   \n");
-      writer.write("   var cntrId = '" + pid + "-counter', cntr = 1;\n");
-      writer.write("   window.setInterval(function () {\n");
-      writer.write("      document.getElementById(cntrId).innerHTML = ++cntr;\n");
-      writer.write("   }, 1000);\n");
-      writer.write("   \n");
-      writer.write("})();\n");
-      writer.write("</script>\n");
-
-      writer.write("<p><hr/></p></div>\n");
 
    }
    

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/d4269e94/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-csp.jsp
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-csp.jsp b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-csp.jsp
new file mode 100644
index 0000000..7ce9442
--- /dev/null
+++ b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-csp.jsp
@@ -0,0 +1,150 @@
+<%--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed  under the  License is distributed on an "AS IS" BASIS,
+WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+implied.
+
+See the License for the specific language governing permissions and
+limitations under the License.
+--%>
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/portlet_2_0"  prefix="portlet" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ page import="static basic.portlet.Constants.*" %>
+
+<portlet:defineObjects />
+
+<h3>Color Selector &amp; Message Sender</h3><hr/>
+      
+<%      
+   String clr = renderRequest.getParameter(PARAM_COLOR);
+   clr = (clr == null) ? "#FFFFFF" : clr;
+   
+   String[] vals = renderRequest.getParameterValues(PARAM_FG_COLOR);
+   String r = "";
+   String g = "";
+   String b = "";
+   if (vals != null) {
+      for (String v : vals) {
+         if (v.equals(PARAM_FG_RED)) r = "checked";
+         if (v.equals(PARAM_FG_GREEN)) g = "checked";
+         if (v.equals(PARAM_FG_BLUE)) b = "checked";
+      }
+      }
+%>
+
+<FORM id='<portlet:namespace/>-setParams'  onsubmit='return false;'>
+   <table><tr><td align='left'>
+
+   Enter background color (public param):
+   </td><td colspan=3>
+   <input id='<portlet:namespace/>-color' name='" + PARAM_COLOR + "' type='text' value='<%=clr%>' size='10' maxlength='10'>
+   </td><td><div id='<portlet:namespace/>-putMsgHere'>
+   </div></td></tr><tr><td>
+
+   Select active foreground colors:
+   </td><td>
+   <input id='<portlet:namespace/>-red' name='" + PARAM_FG_COLOR + "' value='" + PARAM_FG_RED + "' type='checkbox' <%=r%>>
+   </td><td>Red
+   </td><td>
+   <input id='<portlet:namespace/>-green'  name='" + PARAM_FG_COLOR + "' value='" + PARAM_FG_GREEN + "' type='checkbox' <%=g%>>
+   </td><td>Green
+   </td><td>
+   <input id='<portlet:namespace/>-blue'  name='" + PARAM_FG_COLOR + "' value='" + PARAM_FG_BLUE + "' type='checkbox' <%=b%>>
+   </td><td>Blue
+
+   </td></tr><tr><td>
+   Enter message:
+   </td><td colspan=6>
+   <input id='<portlet:namespace/>-msg' name='" + PARAM_MSG_INPUT + "' type='text' value='' size='50' maxlength='50'>
+   </td><td>
+
+   </td></tr><tr><td>
+   <INPUT id ='<portlet:namespace/>-send' VALUE='send' TYPE='button'>
+   </td></tr></table>
+</FORM>
+<p><hr/></p>
+
+<script>
+(function () {
+   'use strict';
+    
+   var pid = '<portlet:namespace/>',
+       colorEntry = '<portlet:namespace/>-color',
+       msgdiv = '<portlet:namespace/>-putMsgHere',
+       sendbtn = '<portlet:namespace/>-send',
+       rid = '<portlet:namespace/>-red',
+       gid = '<portlet:namespace/>-green',
+       bid = '<portlet:namespace/>-blue',
+       mid = '<portlet:namespace/>-msg',
+       currState,
+       portletInit,
+
+       
+   // Handler for onStateChange event
+   update = function (type, state) {
+      var oldColor = ((currState === undefined) || (currState.parameters.color === undefined)) ? '#FFFFFF' : currState.parameters.color[0],
+          newColor = (state.parameters.color === undefined) ? '#FFFFFF' : state.parameters.color[0];
+      console.log("CSP: state updated. Type=" + type + ", color=" + newColor);
+      if ((currState === undefined) || (newColor !== oldColor)) {
+         document.getElementById(msgdiv).innerHTML = '';
+         document.getElementById(colorEntry).value = newColor;
+      }
+      currState = state;
+   };
+   
+
+   // Register portlet with Portlet Hub. Add listener for onStateChange event.
+   portlet.register(pid).then(function (pi) {
+      console.log("CSP Color Selection Portlet: registered: " + pid);
+      portletInit = pi;
+      portletInit.addEventListener("portlet.onStateChange", update);
+   });
+   
+
+   // Handle change in background color entry field
+   document.getElementById(colorEntry).onchange = function () {
+      var newColor = this.value, newState;
+      console.log("CSP: entry field updated. color=" + newColor);
+      if ((newColor === undefined) || (newColor === null) || !newColor.match("^#(?:[A-Fa-f0-9]{3}){1,2}$")) {
+         document.getElementById(msgdiv).innerHTML = 'Bad color. Enter #xxxxxx or #xxx.';
+      } else {
+         newState = portletInit.cloneState(currState);
+         newState.parameters.color = [newColor];
+         portletInit.setPortletState(newState);
+      }
+   };
+   
+
+   // Handler for 'send' button click. Perform partial action.
+   document.getElementById(sendbtn).onclick = function () {
+      var parms = {}, clrs = [];
+      console.log("CSP: sending message.");
+      parms.action = ['send'];
+      if (document.getElementById(rid).checked) {
+         clrs.push("red");
+      } 
+      if (document.getElementById(gid).checked) {
+         clrs.push("green");
+      } 
+      if (document.getElementById(bid).checked) {
+         clrs.push("blue");
+      } 
+      if (clrs.length > 0) {
+         parms.fgcolor = clrs;
+      }
+      parms.imsg = [document.getElementById(mid).value];
+      portletInit.action(parms);
+   };
+      
+}());
+</script>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/d4269e94/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-isp.jsp
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-isp.jsp b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-isp.jsp
new file mode 100644
index 0000000..92b4cd6
--- /dev/null
+++ b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-isp.jsp
@@ -0,0 +1,156 @@
+<%--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed  under the  License is distributed on an "AS IS" BASIS,
+WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+implied.
+
+See the License for the specific language governing permissions and
+limitations under the License.
+--%>
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/portlet_2_0"  prefix="portlet" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+
+<portlet:defineObjects />
+
+
+<h3>Image Selector</h3><hr/>
+<FORM id='<portlet:namespace/>-setParams' onsubmit='return false;'>
+   <table><tr><td align='left'>
+   Selection type (private param):
+   </td><td>
+   <input id='<portlet:namespace/>-radio' type='radio' name='selType' value='radio'>Radio Button
+   <input id='<portlet:namespace/>-dropdown' type='radio' name='selType' value='dropdown'>Drop Down
+   </td></tr><tr><td>
+   Select Image (public param):
+   </td><td>
+
+   <div id='<portlet:namespace/>-putResourceHere'></div>
+
+   </td></tr></table>
+</FORM>
+<p><hr/></p>
+
+<script>
+(function () {
+   'use strict';
+   
+   var pid = '<portlet:namespace/>',
+       fid = '<portlet:namespace/>-setParams',
+       resdiv = '<portlet:namespace/>-putResourceHere',
+       st_radio = '<portlet:namespace/>-radio',
+       st_dropdown = '<portlet:namespace/>-dropdown',
+       selBox = '<portlet:namespace/>-selBox',
+   
+       currState,
+       portletInit,
+   
+   // Set image name PRP if radio button clicked - 
+   handleImgRadio = function () {
+      console.log("ISP: image selected (radio): " + this.value);
+      
+      if (currState.parameters.imgName !== this.value) {
+         var newState = portletInit.cloneState(currState);
+         newState.parameters.imgName = [this.value];
+         portletInit.setPortletState(newState);
+      }
+   },
+   
+   // Set image name PRP if image selected in selection box - 
+   handleImgDropdown = function () {
+      console.log("ISP: image selected (dropdown): " + this.value);
+      
+      if (currState.parameters.imgName !== this.value) {
+         var newState = portletInit.cloneState(currState);
+         newState.parameters.imgName = [this.value];
+         portletInit.setPortletState(newState);
+      }
+   },
+   
+   // Handler for onStateChange event
+   update = function (type, state) {
+      var oldST = ((currState === undefined) || (currState.parameters.selType === undefined)) ? undefined : currState.parameters.selType[0],
+          newST = (state.parameters.selType === undefined) ? undefined : state.parameters.selType[0],
+          newImg = (state.parameters.imgName === undefined) ? undefined : state.parameters.imgName[0];
+          
+      console.log("ISP: state updated. type=" + type + ", selType=" + newST + ", imgName=" + newImg);
+      
+      if ((currState === undefined) || (oldST !== newST)) {
+         portletInit.createResourceUrl({}).then(function (url) {
+            console.log("ISP: got url: " + url);
+            var xhr = new XMLHttpRequest();
+            xhr.onreadystatechange=function() {
+               if (xhr.readyState === 4 && xhr.status === 200) {
+                  document.getElementById(resdiv).innerHTML = xhr.responseText;
+
+                  // default is radio buttons
+                  var ii, f = document.getElementById(fid);
+                  if ((newST === undefined) || (newST === 'radio')) {
+                     for (ii=0; ii < f.imgName.length; ii++) {
+                        console.log("ISP: adding selection handler for: " + f.imgName[ii].value);
+                        f.imgName[ii].onclick = handleImgRadio;
+                        if (f.imgName[ii].value === newImg) {
+                           console.log("ISP: image clicked: " + newImg);
+                           f.imgName[ii].clicked = true;
+                        }
+                     }
+                  } else if (newST === 'dropdown') {
+                     console.log("ISP: adding selection handler to dropdown list element: " + selBox);
+                     document.getElementById(selBox).onchange = handleImgDropdown;
+                     for (ii=0; ii < f.imgName.length; ii++) {
+                        if (f.imgName[ii].value === newImg) {
+                           console.log("ISP: image selected: " + newImg);
+                           f.imgName[ii].selected = true;
+                        }
+                     }
+                  }
+
+               }
+            };
+            xhr.open("GET",url,true);
+            xhr.send();
+         });
+      }
+
+      if (newST === 'dropdown') {
+         document.getElementById(st_dropdown).checked = true;
+      } else {
+         document.getElementById(st_radio).checked = true;
+      }
+
+      currState=state;
+   },
+   
+   // set private parameter selType to store the selection display type
+   handleST = function () {
+      console.log("ISP: select display type clicked: " + this.value);
+      if (currState.parameters.selType !==  this.value) {
+         var newState = portletInit.cloneState(currState);
+         newState.parameters.selType = [this.value];
+         portletInit.setPortletState(newState);
+      }
+   };
+   
+   document.getElementById(st_radio).onclick = handleST;
+   document.getElementById(st_dropdown).onclick = handleST;
+   
+   
+   // Register with Portlet Hub, add listener for onStateChange event
+   portlet.register(pid).then(function (pi) {
+      console.log("ISP Image Selection Portlet: registered: " + pid);
+      portletInit = pi;
+      portletInit.addEventListener("portlet.onStateChange", update);
+   });
+   
+   
+}());
+</script>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/d4269e94/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-ivp.jsp
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-ivp.jsp b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-ivp.jsp
new file mode 100644
index 0000000..67c07d3
--- /dev/null
+++ b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-ivp.jsp
@@ -0,0 +1,125 @@
+<%--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed  under the  License is distributed on an "AS IS" BASIS,
+WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+implied.
+
+See the License for the specific language governing permissions and
+limitations under the License.
+--%>
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/portlet_2_0"  prefix="portlet" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+
+<portlet:defineObjects />
+
+<div style='clear:both;'>
+<div style='float:left;'><h3>Image Viewer</h3></div>
+<div id=<portlet:namespace/>-counter style='float:right; font-size:250%; color:#0B0;'>1</div>
+</div><div style='clear:both;'><hr/>
+      
+<FORM id='<portlet:namespace/>-setParams'  onsubmit='return false;'>
+   <table><tr><td align='left'>
+   Cacheability setting:
+   </td><td>
+   <input id='<portlet:namespace/>-page' type='radio' name='cacheability' value='cacheLevelPage'>Page
+   <input id='<portlet:namespace/>-portlet' type='radio' name='cacheability' value='cacheLevelPortlet'>Portlet
+   <input id='<portlet:namespace/>-full' type='radio' name='cacheability' value='cacheLevelFull'>Full
+   </td></tr><tr><td>
+   Set border (resource parameter)
+   </td><td>
+   <input id='<portlet:namespace/>-border' type='checkbox' name='border' value='border'>
+   </td></tr></table>
+</FORM><hr/>
+
+<div id='<portlet:namespace/>-putResourceHere'></div>
+      
+<script>
+(function () {
+   'use strict';
+   
+   var pid = '<portlet:namespace/>',
+       resdiv = '<portlet:namespace/>-putResourceHere',
+       border = '<portlet:namespace/>-border',
+       ca_page = '<portlet:namespace/>-page',
+       ca_portlet = '<portlet:namespace/>-portlet',
+       ca_full = '<portlet:namespace/>-full',
+
+       cntrId = '<portlet:namespace/>-counter', 
+       cntr = 1,
+       
+       resparms = {},
+       cacheability = 'cacheLevelPage',
+       portletInit,
+   
+   // Update function called by the Portlet Hub when an onStatechange event occurs. 
+   update = function (type, state) {
+      console.log("Resource Portlet: state updated. event type=" + type);
+      
+      portletInit.createResourceUrl(resparms, cacheability).then(function (url) {
+         var brdr = (resparms.border === undefined) ? undefined : resparms.border[0],
+             xhr = new XMLHttpRequest();
+         console.log("Resource Portlet: got url: " + url + ", res parm border=" + brdr);
+         xhr.onreadystatechange = function () {
+            if (xhr.readyState === 4 && xhr.status === 200) {
+               document.getElementById(resdiv).innerHTML=xhr.responseText;
+            }
+         };
+         xhr.open("GET",url,true);
+         xhr.send();
+      });
+   },
+   
+   // Handler for cacheability radio buttons
+   handleCA = function () {
+      console.log("cacheability button clicked: " + this.value);
+      if (cacheability !== this.value) {
+         cacheability = this.value;
+         update();
+      }
+   };
+   
+   document.getElementById(ca_page).checked = true;
+   document.getElementById(ca_page).onclick = handleCA;
+   document.getElementById(ca_portlet).onclick = handleCA;
+   document.getElementById(ca_full).onclick = handleCA;
+   
+   // Handler for 'border' checkbox 
+   document.getElementById(border).checked = false;
+   document.getElementById(border).onclick = function () {
+      console.log("border checked: " + this.checked);
+      if (this.checked) {
+         resparms.border = ['#00F'];
+      } else {
+         resparms = {};
+      }
+      update();
+   };
+   
+   // Register this portlet with the Portlet Hub and add event listener for 
+   // the onStateChange event
+   portlet.register(pid).then(function (pi) {
+      console.log("registered: " + pid);
+      portletInit = pi;
+      portletInit.addEventListener("portlet.onStateChange", update);
+   });
+   
+   // Simple counter for demonstrating that page hasn't been refreshed.
+   window.setInterval(function () {
+      document.getElementById(cntrId).innerHTML = ++cntr;
+   }, 1000);
+   
+}());
+</script>
+
+<p><hr/></p></div>
+

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/d4269e94/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-mbp.jsp
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-mbp.jsp b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-mbp.jsp
new file mode 100644
index 0000000..deda0c8
--- /dev/null
+++ b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view-mbp.jsp
@@ -0,0 +1,89 @@
+<%--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed  under the  License is distributed on an "AS IS" BASIS,
+WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+implied.
+
+See the License for the specific language governing permissions and
+limitations under the License.
+--%>
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/portlet_2_0"  prefix="portlet" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+
+<portlet:defineObjects />
+
+<%
+   StringBuffer style = new StringBuffer(256);
+   style.append("border-style:solid; border-width:3px;");
+   style.append(" padding:4px; overflow:auto;");
+   style.append(" border-color:#000088; min-height:70px;");
+   style.append(" background:#E0E0E0;");
+%>
+
+<div style='clear:both;'>
+<div style='float:left;'><h3>Image Viewer</h3></div>
+<div style='float:right;'>
+<form   onsubmit='return false;'><input id='<portlet:namespace/>-clear' type='submit' name='action' value='clear' /></form>
+</div>
+</div><div style='clear:both;'><hr/>
+<h3>Message Box Portlet</h3>
+<p>Messages that arrive via events from other portlets are displayed in this box.</p>
+<div id='<portlet:namespace/>-responseDiv' style="<%=style.toString()%>"></div>
+</div>
+   
+<script>
+(function () {
+   'use strict';
+   var pid = '<portlet:namespace/>',
+       resdiv = '<portlet:namespace/>-responseDiv',
+       clrButton = '<portlet:namespace/>-clear',
+   
+       state,
+       resparms = {},
+       cacheability = 'cacheLevelPage',
+       portletInit,
+   
+   // Handler for onStateChange event
+   update = function (type, s) {
+      console.log("Resource Portlet: state updated. Event type = " + type);
+      state = s;
+      
+      portletInit.createResourceUrl(resparms, cacheability).then(function (url) {
+         var brdr = (resparms.border === undefined) ? undefined : resparms.border[0],
+             xhr = new XMLHttpRequest();
+         console.log("Resource Portlet: got url: " + url + ", res parm border=" + brdr);
+         xhr.onreadystatechange=function() {
+            if (xhr.readyState === 4 && xhr.status === 200) {
+               document.getElementById(resdiv).innerHTML=xhr.responseText;
+            }
+         };
+         xhr.open("GET",url,true);
+         xhr.send();
+      });
+   };
+   
+   // Handler for "clear" button. execute an action which clears the stored messages
+   document.getElementById(clrButton).onclick = function () {
+      console.log("clear button clicked. ");
+      portletInit.action();
+   };
+   
+   // Register portlet with Portlet Hub; add onStateChange listener 
+   portlet.register(pid).then(function (pi) {
+      console.log("Message Box portlet registered: " + pid);
+      portletInit = pi;
+      portletInit.addEventListener("portlet.onStateChange", update);
+   });
+   
+}());
+</script>

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/d4269e94/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view.jsp
----------------------------------------------------------------------
diff --git a/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view.jsp b/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view.jsp
deleted file mode 100644
index b0ba96c..0000000
--- a/PortletHubDemo/src/main/webapp/WEB-INF/jsp/view.jsp
+++ /dev/null
@@ -1,27 +0,0 @@
-<%@ page session="false" %>
-<%@ taglib uri="http://java.sun.com/portlet_2_0"  prefix="portlet" %>
-<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-
-<portlet:defineObjects />
-
-<H3>PRP Resource Portlet</H3>
-<P>Sample Resource Portlet application that demonstrates image loading based on a public render parameter.</P>
-
-<!-- Display a button that causes some parameters to be set -->
-<FORM METHOD="POST" ACTION="<portlet:actionURL/>">
-	<INPUT NAME='action' VALUE='setParms' TYPE="hidden">
-    <INPUT VALUE="Set Parameters" CLASS="portlet-form-button" TYPE="submit">
-</FORM>
-
-<!-- Display the parameters for the portlet -->
-<P>Parameters:</P>
-<UL>
-<c:forEach var="name" items="${renderRequest.getParameterNames()}">
-   <c:forEach var="value" items="${renderRequest.getParameterValues(name)}">
-      <LI>
-         Name: ${name}, Val: ${value}
-      </LI>
-   </c:forEach>
-</c:forEach>
-</UL>
-


Mime
View raw message