2 Replies Latest reply on Oct 3, 2007 8:45 AM by habicht hawk

    jboss ipc

    habicht hawk Newbie

      hello

      i'm trying to solve i problem i have with jboss ipc in the example from the reference guide. i have everything configured according to the reference guide (*-object.xml, jboss-service.xml, sar-achrive). everything deployes fine without problems. when i try nothing happens. the parameters don't show up on the second portlet. even after that there are no errors in my log and according to that log my listener defined in the jboss-service.xml is registered.
      my first problem i had with this example is now solved. it was because i didn't have the right structure of the sar-file (which caused a NoClassDefFound-Exception)

      my-object.xml:

      <page-name>test</page-name>
       <properties/>
       <window>
       <window-name>test1-window</window-name>
       <instance-ref>AInstance</instance-ref>
       <region>center</region>
       <height>0</height>
       </window>
       <window>
       <window-name>test2-window</window-name>
       <instance-ref>BInstance</instance-ref>
       <region>center</region>
       <height>0</height>
       <listener>test_listener</listener>
       </window>


      jboss-service.xml:
      <?xml version="1.0" encoding="UTF-8"?>
      <server>
       <mbean
       code="org.jboss.portal.core.event.PortalEventListenerServiceImpl"
       name="portal:service=ListenerService,type=test_listener"
       xmbean-dd=""
       xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
       <xmbean/>
       <depends
       optional-attribute-name="Registry"
       proxy-type="attribute">portal:service=ListenerRegistry</depends>
       <attribute name="RegistryId">test_listener</attribute>
       <attribute name="ListenerClassName">test.PortletB$Listener</attribute>
      </mbean>
      </server>


      PortletB.java
      package test;
      
      import java.io.IOException;
      import java.io.PrintWriter;
      
      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 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;
      
      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("test1-window") && event instanceof WindowActionEvent)
       {
       // Find window B
       WindowActionEvent wae = (WindowActionEvent)event;
       PortalNode windowB = node.resolve("../test2-window");
       if (windowB != null)
       {
       // We can redirect
       newEvent = new WindowActionEvent(windowB);
       newEvent.setParameters(wae.getParameters());
      
       // Due to a bug those 2 following lines are required but have no meaning for now
       // See: http://jira.jboss.com/jira/browse/JBPORTAL-1604
       newEvent.setMode(wae.getMode());
       newEvent.setWindowState(WindowState.MAXIMIZED);
      
       // Redirect to the new event
       return newEvent;
       }
       }
       // Otherwise bubble up
       return context.dispatch();
       }
       }
      }


      PortletA.java
      package test;
      
      import java.io.IOException;
      import java.io.PrintWriter;
      
      import javax.portlet.GenericPortlet;
      import javax.portlet.PortletException;
      import javax.portlet.PortletSecurityException;
      import javax.portlet.RenderRequest;
      import javax.portlet.RenderResponse;
      
      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.createRenderURL() + "\" 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();
       }
      }


      my system:
      Windows XP Pro SP2
      Java 1.5.0_09
      JBoss Portal 2.6 Bundle (binary)
      PostgreSQL 8.3


        • 1. Re: jboss ipc
          Thomas Heute Master

          In your listener you wrote:

          if (nodeName.equals("test1-window") && event instanceof WindowActionEvent)

          But you are listening on test2-window,
          so your code inside is never called.

          With a debugger you would have seen that easily.

          • 2. Re: jboss ipc
            habicht hawk Newbie

            can someone tell me a way to get two listeners listening on one portlet? everytime i try something like that i get an exception that a listener is already registered (although they are named differently).

            i have the three portlets top, side and content. side's actions are depending on a paremeter passed on from top. content's actions are depending on the parameters passed on from top and side. i would need that to create a navitagion generated dynamically out of a database. top shows the first navigation level. if i select something from top, side should show the next level beneath the one selected in top and the content-portlet should show an index.html which is in the selected point. if i select something from side the content-portlet should show the content beneath that point.

            is there a way to do this with three seperate portlets or are there better alternatives?

            thanks in advance
            habicht