Author: chris.laprun(a)jboss.com
Date: 2009-01-07 18:21:18 -0500 (Wed, 07 Jan 2009)
New Revision: 12449
Modified:
modules/portlet/trunk/samples/src/main/artifacts/google-portlet-war/WEB-INF/portlet.xml
modules/portlet/trunk/samples/src/main/artifacts/remotecontroller-portlet-war/WEB-INF/portlet.xml
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/google/GoogleClippingPortlet.java
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/remotecontroller/RemoteControllerPortlet.java
Log:
- JBPORTAL-2238: Trying to get remote window to refresh when main page is refreshed... Not
working yet.
- doHeaders doesn't seem to be working either...
- Google portlet now publishes zip as an event as well in case portlets are interested in
it
Modified:
modules/portlet/trunk/samples/src/main/artifacts/google-portlet-war/WEB-INF/portlet.xml
===================================================================
---
modules/portlet/trunk/samples/src/main/artifacts/google-portlet-war/WEB-INF/portlet.xml 2009-01-07
19:34:24 UTC (rev 12448)
+++
modules/portlet/trunk/samples/src/main/artifacts/google-portlet-war/WEB-INF/portlet.xml 2009-01-07
23:21:18 UTC (rev 12449)
@@ -63,6 +63,9 @@
<read-only>false</read-only>
</preference>
</portlet-preferences>
+ <supported-publishing-event>
+ <qname
xmlns:jbp='urn:jboss:portal:samples:event'>jbp:ZipEvent</qname>
+ </supported-publishing-event>
<supported-public-render-parameter>zipcode</supported-public-render-parameter>
</portlet>
@@ -107,6 +110,11 @@
<supported-public-render-parameter>zipcode</supported-public-render-parameter>
</portlet>
+ <event-definition>
+ <qname
xmlns:jbp='urn:jboss:portal:samples:event'>jbp:ZipEvent</qname>
+ <value-type>java.lang.String</value-type>
+ </event-definition>
+
<public-render-parameter>
<identifier>zipcode</identifier>
<qname
xmlns:g='urn:jboss:portal:simple:google'>g:zipcode</qname>
Modified:
modules/portlet/trunk/samples/src/main/artifacts/remotecontroller-portlet-war/WEB-INF/portlet.xml
===================================================================
---
modules/portlet/trunk/samples/src/main/artifacts/remotecontroller-portlet-war/WEB-INF/portlet.xml 2009-01-07
19:34:24 UTC (rev 12448)
+++
modules/portlet/trunk/samples/src/main/artifacts/remotecontroller-portlet-war/WEB-INF/portlet.xml 2009-01-07
23:21:18 UTC (rev 12449)
@@ -52,5 +52,10 @@
<identifier>zipcode</identifier>
<qname
xmlns:g='urn:jboss:portal:simple:google'>g:zipcode</qname>
</public-render-parameter>
+
+ <container-runtime-option>
+ <name>javax.portlet.renderHeaders</name>
+ <value>true</value>
+ </container-runtime-option>
</portlet-app>
Modified:
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/google/GoogleClippingPortlet.java
===================================================================
---
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/google/GoogleClippingPortlet.java 2009-01-07
19:34:24 UTC (rev 12448)
+++
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/google/GoogleClippingPortlet.java 2009-01-07
23:21:18 UTC (rev 12449)
@@ -31,6 +31,7 @@
import javax.portlet.PortletPreferences;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
+import javax.xml.namespace.QName;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -55,6 +56,8 @@
private static final String BEGINNING_STRING = "beginningString";
private static final String QUERY = "query";
+ public static final QName QNAME = new
QName("urn:jboss:portal:samples:event", "ZipEvent");
+
/**
* gl=US forces use of US google site, hl=en forces results to be in English so that
regardless of location the query
* should result in the expected result.
@@ -159,6 +162,9 @@
// request view
actionResponse.setPortletMode(PortletMode.VIEW);
+
+ // send out zip event
+ actionResponse.setEvent(QNAME, zip);
}
protected String postProcessHTML(String html)
Modified:
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/remotecontroller/RemoteControllerPortlet.java
===================================================================
---
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/remotecontroller/RemoteControllerPortlet.java 2009-01-07
19:34:24 UTC (rev 12448)
+++
modules/portlet/trunk/samples/src/main/java/org/jboss/portal/portlet/samples/remotecontroller/RemoteControllerPortlet.java 2009-01-07
23:21:18 UTC (rev 12449)
@@ -30,16 +30,35 @@
renderResponse.setContentType("text/html");
PrintWriter printWriter = renderResponse.getWriter();
String namespace = renderResponse.getNamespace();
- printWriter.print("<script type='text/javascript'>function
" + namespace
- + "_openRemote(url){window.name='" + namespace +
"_parent';window.open(url, '" + namespace
- + "_remote',
'width=400,height=200,scrollable=yes')}</script>");
- printWriter.print("<p><a href='#' onclick=\"" +
namespace + "_openRemote('");
+ printWriter.print("<p><a href='#' onclick=\"" +
namespace + "_remote=" + namespace + "_openRemote('");
ResourceURL resource = renderResponse.createResourceURL();
printWriter.print(resource);
printWriter.print("')\">Open remote
control!</a></p>");
-}
+ }
@Override
+ protected void doHeaders(RenderRequest renderRequest, RenderResponse renderResponse)
+ {
+ PrintWriter printWriter = null;
+ try
+ {
+ printWriter = renderResponse.getWriter();
+ String namespace = renderResponse.getNamespace();
+ String remoteWindowName = namespace + "_remote";
+ printWriter.print("<script type='text/javascript'>var "
+ remoteWindowName + "; function " + namespace
+ + "_openRemote(url){window.name='" + namespace +
"_parent';window.open(url, '" + remoteWindowName
+ + "', 'width=400,height=200,scrollable=yes')}" +
+ "onload = function() {" +
+ "if (typeof " + remoteWindowName + " != 'undefined')
{" + remoteWindowName + ".location.reload(true);}" +
+ "}</script>");
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace(); //To change body of catch statement use File | Settings |
File Templates.
+ }
+ }
+
+ @Override
public void serveResource(ResourceRequest resourceRequest, ResourceResponse
resourceResponse) throws PortletException, IOException
{
resourceResponse.setContentType("text/html");
Show replies by date