2 Replies Latest reply on Jul 2, 2008 12:18 AM by Paida Kumar

    IPC problem

    Senthil Kumar Newbie

      Hi..
      Can anyone help me in IPC problem. I have portlet A and portlet B. I am trying to trigger from portlet A but there is no output and no exceptions. The problem is request havent went for processaction method in porltet B.

      Steps i have followed is...
      1. I have created a war file
      war files contains web-inf and meta-inf.

      in meta-inf i have jboss-service.xml
      Inside this xml i have following code

      <?xml version="1.0" encoding="UTF-8"?>

      <mbean
      code="org.jboss.portal.core.event.PortalEventListenerServiceImpl"
      name="portal:service=ListenerService,type=ipc_listener"
      xmbean-dd=""
      xmbean-code="org.jboss.portal.common.system.JBossServiceModelMBean">

      <depends
      optional-attribute-name="Registry"
      proxy-type="attribute">portal:service=ListenerRegistry
      ipc_listener
      org.jboss.portlet.hello.HelloWorldPortletB$Listener



      under web-inf i have
      helloworld-object.xml
      <?xml version="1.0" encoding="UTF-8"?>


      <parent-ref>default</parent-ref>
      <if-exists>overwrite</if-exists>

      <page-name>IPC</page-name>

      <window-name>
      HelloWorldPortletAWindow
      </window-name>
      <instance-ref>
      HelloWorldPortletAInstance
      </instance-ref>

      center
      1


      <window-name>
      HelloWorldPortletBWindow
      </window-name>
      <instance-ref>
      HelloWorldPortletBInstance
      </instance-ref>
      ipc_listener
      left
      1





      Then i have portlet A class
      package org.jboss.portlet.hello;


      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 Julien Viet
      * @version $Revision: 5448 $
      */
      public class HelloWorldPortletA 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("blue");
      writer.println("red");
      writer.println("black");
      writer.println("");
      writer.println("<input type=\"submit\"/>");
      writer.println("");
      writer.close();
      }

      public void processAction(ActionRequest request, ActionResponse response) throws PortletException
      , PortletSecurityException, IOException
      {
      System.out.println("Entere process action");
      System.out.println("The parameter names are"+request.getParameter("submit"));
      String requestBtn = (String) request.getParameter("submit");
      System.out.println("The request btnis"+requestBtn);
      response.setRenderParameter("submit", requestBtn);

      }
      }

      Then i have portlet B class
      /*****************************************
      * *
      * JBoss Portal: The OpenSource Portal *
      * *
      * Distributable under LGPL license. *
      * See terms of license at gnu.org. *
      * *
      *****************************************/

      package org.jboss.portlet.hello;



      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 Julien Viet
      * @version $Revision: 8785 $
      */
      public class HelloWorldPortletB 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");
      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("HelloWorldPortletAWindow") && event instanceof WindowActionEvent)
      {
      // Find window B
      WindowActionEvent wae = (WindowActionEvent)event;
      PortalNode windowB = node.resolve("../HelloWorldPortletBWindow");
      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();
      }
      }
      }
      }

      There is no exception please help what should i do for my result

      Thanks & Regards,
      Senthil Kumar Devan