Author: julien(a)jboss.com
Date: 2007-02-12 17:33:02 -0500 (Mon, 12 Feb 2007)
New Revision: 6233
Modified:
docs/trunk/referenceGuide/en/modules/ipc.xml
Log:
update IPC section to update with new DTD + cosmetic
Modified: docs/trunk/referenceGuide/en/modules/ipc.xml
===================================================================
--- docs/trunk/referenceGuide/en/modules/ipc.xml 2007-02-12 22:28:08 UTC (rev 6232)
+++ docs/trunk/referenceGuide/en/modules/ipc.xml 2007-02-12 22:33:02 UTC (rev 6233)
@@ -76,17 +76,17 @@
<para>Enabling IPC, also requires that the listener be declared in the
*-object.xml, so the Portal recognizes
it.
The declaration happens at the page level, as in our example:
- <programlisting>
- <![CDATA[
+ <programlisting><![CDATA[<!DOCTYPE deployments PUBLIC
+ "-//JBoss Portal//DTD Portal Object 2.6//EN"
+ "http://www.jboss.org/portal/dtd/portal-object_2_6.dtd">
<deployments>
<deployment>
<parent-ref>default</parent-ref>
<if-exists>overwrite</if-exists>
- <properties/>
<page>
<page-name>IPC</page-name>
<listener>ipc_listener</listener>
- <properties/>...]]>
+ ...]]>
</programlisting>
<note>The
<emphasis>listener</emphasis>
@@ -104,48 +104,46 @@
</para>
<para>In our example, Portlet A will be modifying the behaviour of Portlet
B. So then we will declare the
listener in Portlet B, the recipient portlet.
- <programlisting>
- <![CDATA[
+ <programlisting><![CDATA[
public static class Listener implements PortalNodeEventListener
+{
+ public PortalNodeEvent onEvent(PortalNodeEventContext context, PortalNodeEvent event)
{
- public PortalNodeEvent onEvent(PortalNodeEventContext context, PortalNodeEvent
event)
- {
- PortalNode node = event.getNode();
+ PortalNode node = event.getNode();
- // Get node name
- String nodeName = node.getName();
+ // Get node name
+ String nodeName = node.getName();
- // See if we need to create a new event or not
- WindowActionEvent newEvent = null;
- if(nodeName.equals("HelloWorldPortletAWindow") && event
instanceof WindowActionEvent)
+ // See if we need to create a new event or not
+ WindowActionEvent newEvent = null;
+ if(nodeName.equals("HelloWorldPortletAWindow") && event
instanceof WindowActionEvent)
+ {
+ // Find window B
+ WindowActionEvent wae = (WindowActionEvent) event;
+ PortalNode windowB = node.resolve("../HelloWorldPortletBWindow");
+ if(windowB != null)
{
- // Find window B
- WindowActionEvent wae = (WindowActionEvent) event;
- PortalNode windowB = node.resolve("../HelloWorldPortletBWindow");
- if(windowB != null)
- {
- // We can redirect and modify the view/mode as well!
- newEvent = new WindowActionEvent(windowB);
- newEvent.setMode(wae.getMode());
- //newEvent.setWindowState(WindowState.MAXIMIZED);
- newEvent.setParameters(wae.getParameters());
- }
+ // We can redirect and modify the view/mode as well!
+ newEvent = new WindowActionEvent(windowB);
+ newEvent.setMode(wae.getMode());
+ //newEvent.setWindowState(WindowState.MAXIMIZED);
+ newEvent.setParameters(wae.getParameters());
}
+ }
- //
- if(newEvent != null)
- {
- // If we have a new event redirect to it
- return newEvent;
- }
- else
- {
- // Otherwise bubble up
- return context.dispatch();
- }
+ //
+ if(newEvent != null)
+ {
+ // If we have a new event redirect to it
+ return newEvent;
}
- }]]>
- </programlisting>
+ else
+ {
+ // Otherwise bubble up
+ return context.dispatch();
+ }
+ }
+}]]></programlisting>
</para>
<para>
It is important to note here some of the important items in this listener
class.
@@ -163,8 +161,8 @@
<para>
Modify Portlet B windowmode and/or windowstate (ie, Maximize and place in
Edit Mode):
<programlisting>
- newEvent.setMode(wae.getMode()); // Mode.EDIT;
- newEvent.setWindowState(wae.getWindowState()); //
WindowState.MAXIMIZED</programlisting>
+newEvent.setMode(wae.getMode()); // Mode.EDIT;
+newEvent.setWindowState(wae.getWindowState()); //
WindowState.MAXIMIZED</programlisting>
</para>
</sect2>
</sect1>
@@ -172,18 +170,16 @@
<title>Communicating with another Portlet</title>
<para>
Creating a link from Portlet A to Portlet B occurs in the same way you would
normally create a PortletURL:
- <programlisting>
- <![CDATA[
- html.append("<form action=\"" + resp.createActionURL() +
"\" method=\"post\">");
- html.append("<input type=\"text\"
name=\"sometext\"><br/>");
- html.append("<select name=\"color\">");
- html.append("<option>blue</option>");
- html.append("<option>red</option>");
- html.append("<option>black</option>");
- html.append("</select>");
- html.append("<input type=\"submit\"/>");
- html.append("</form>");]]>
- </programlisting>
+ <programlisting><![CDATA[
+html.append("<form action=\"" + resp.createActionURL() + "\"
method=\"post\">");
+html.append("<input type=\"text\"
name=\"sometext\"><br/>");
+html.append("<select name=\"color\">");
+html.append("<option>blue</option>");
+html.append("<option>red</option>");
+html.append("<option>black</option>");
+html.append("</select>");
+html.append("<input type=\"submit\"/>");
+html.append("</form>");]]></programlisting>
As you can see from the code above, we are creating a simple HTML form with an
ActionURL from within Portlet A.
It will target itself, but be intercepted by the listener, created in Portlet B.
This form passes some text and
a color value from input fields.
@@ -191,19 +187,17 @@
<para>
Now, in Portlet B, our listener innerclass will trigger the processAction() in
Portlet B, reading in the
parameters from the Portlet A form:
- <programlisting>
- <![CDATA[
- public void processAction(JBossActionRequest request, JBossActionResponse response)
throws PortletException, PortletSecurityException, IOException
+ <programlisting><![CDATA[
+public void processAction(JBossActionRequest request, JBossActionResponse response)
throws PortletException, PortletSecurityException, IOException
+{
+ String color = request.getParameter("color");
+ String text = request.getParameter("sometext");
+ if(color != null && text != null)
{
- String color = request.getParameter("color");
- String text = request.getParameter("sometext");
- if(color != null && text != null)
- {
- response.setRenderParameter("color", color);
- response.setRenderParameter("sometext", text);
- }
- }]]>
- </programlisting>
+ response.setRenderParameter("color", color);
+ response.setRenderParameter("sometext", text);
+ }
+}]]></programlisting>
Setting the render parameters, it will now pass them on to the Portlet B,
doView();
</para>
@@ -219,7 +213,7 @@
, you can see the basics of creating a link to a Portal Page. I have added
comments in-line to explain the code
sample below:
<programlisting>
- <![CDATA[
+<![CDATA[
// Get the ParentNode. Since we are inside a Window, the Parent is the Page
PortalNode thisNode = req.getPortalNode().getParent();
@@ -232,8 +226,7 @@
// Output the Node's name and URL for users
html.append("Page: " + linkToNode.getName() + " -> ");
html.append("<a href=\"" + pageURL.toString() + "\">"
+ linkToNode.getName() + "</a>");
- ]]>
- </programlisting>
+ ]]></programlisting>
</para>
</sect1>
</chapter>
Show replies by date