[jboss-user] [JBoss Portal] - Re: problem with IPC
sbiwal
do-not-reply at jboss.com
Sun Apr 13 06:03:01 EDT 2008
Also posting code for PortletA and PortletB
PortletA.java
| package org.jboss.portal.core.samples.basic.event;
|
| import javax.portlet.ActionRequest;
| import javax.portlet.ActionResponse;
| import javax.portlet.GenericPortlet;
| import javax.portlet.PortletException;
| import javax.portlet.PortletSecurityException;
| import javax.portlet.RenderRequest;
| import javax.portlet.RenderResponse;
| import java.io.IOException;
| import java.io.PrintWriter;
|
| /**
| * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
| * @version $Revision: 5448 $
| */
| public class PortletA extends GenericPortlet
| {
| protected void doView(RenderRequest request, RenderResponse response) throws PortletException, PortletSecurityException, IOException
| {
| response.setContentType("text/html");
| PrintWriter writer = response.getWriter();
| writer.println("<form action=\"" + response.createActionURL() + "\" method=\"post\">");
| writer.println("<select name=\"color\">");
| writer.println("<option>blue</option>");
| writer.println("<option>red</option>");
| writer.println("<option>black</option>");
| writer.println("</select>");
| writer.println("<input type=\"submit\"/>");
| writer.println("</form>");
| writer.close();
| }
| }
|
PortletB.java
| package org.jboss.portal.core.samples.basic.event;
|
| import org.jboss.portal.WindowState;
| import org.jboss.portal.api.node.PortalNode;
| import org.jboss.portal.api.node.event.PortalNodeEvent;
| import org.jboss.portal.api.node.event.PortalNodeEventContext;
| import org.jboss.portal.api.node.event.PortalNodeEventListener;
| import org.jboss.portal.api.node.event.WindowActionEvent;
|
| import javax.portlet.ActionRequest;
| import javax.portlet.ActionResponse;
| import javax.portlet.GenericPortlet;
| import javax.portlet.PortletException;
| import javax.portlet.PortletSecurityException;
| import javax.portlet.RenderRequest;
| import javax.portlet.RenderResponse;
| import java.io.IOException;
| import java.io.PrintWriter;
|
| /**
| * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
| * @version $Revision: 8785 $
| */
| public class PortletB extends GenericPortlet
| {
|
| public void processAction(ActionRequest request, ActionResponse response) throws PortletException, PortletSecurityException, IOException
| {
| String color = request.getParameter("color");
| if (color != null)
| {
| response.setRenderParameter("color", color);
| }
| }
|
| protected void doView(RenderRequest request, RenderResponse response) throws PortletException, PortletSecurityException, IOException
| {
| String color = request.getParameter("color");
| response.setContentType("text/html");
| PrintWriter writer = response.getWriter();
| writer.println("<div" +
| (color == null ? "" : " style=\"color:" + color + ";\"") +
| ">some text in color</div>");
| writer.close();
| }
|
| public static class Listener implements PortalNodeEventListener
| {
| public PortalNodeEvent onEvent(PortalNodeEventContext context, PortalNodeEvent event)
| {
| PortalNode node = event.getNode();
|
| // Get node name
| String nodeName = node.getName();
|
| // See if we need to create a new event or not
| WindowActionEvent newEvent = null;
| if (nodeName.equals("PortletAWindow") && event instanceof WindowActionEvent)
| {
| // Find window B
| WindowActionEvent wae = (WindowActionEvent)event;
| PortalNode windowB = node.resolve("../PortletBWindow");
| if (windowB != null)
| {
| // We can redirect
| newEvent = new WindowActionEvent(windowB);
| 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();
| }
| }
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4143698#4143698
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4143698
More information about the jboss-user
mailing list