使用Vaadin portlet在Liferay 6.1中进行Portlet间通信

时间:2012-10-10 04:52:08

标签: liferay vaadin

我有一个要求,比如在Liferay中传递两个vaadin portlet。 一个portlet带有vaadin树视图,显示报告名称(webi报告)。点击树时,我必须在另一个portlet中打开相应的报告。

任何人都可以建议您的想法并分享满足此要求的详细信息。

提前做出来。

2 个答案:

答案 0 :(得分:1)

一个简单的解决方案是Vaadin IPC附加组件。请参阅以下网址查看详情和示例:http://vaadin.com/addon/vaadin-ipc-for-liferay

请注意,这需要使用6.x版本的Vaadin。

答案 1 :(得分:0)

I have instlled vaadin control panel for liferay and installed vaadin liferay ipc in tomcat.
The below codes of two portlets sender and receiver .But I cannt able to receive.PLease help in solving this 

**sender :**

import com.vaadin.Application;
import com.vaadin.addon.ipcforliferay.LiferayIPC;
import com.vaadin.ui.Label;
import com.vaadin.ui.Window;

@SuppressWarnings("serial")
public class SenderipcApplication extends Application {

    public void init() {
        Window window = new Window();

        setMainWindow(window);

        Label label = new Label("Hello Senderipc!");

        window.addComponent(label);

        LiferayIPC ipc = new LiferayIPC();
        ipc.sendEvent("eventid1", "This is sender 1");

        window.addComponent(ipc);
    }

}



**receiver**

package senderipc;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.EventRequest;
import javax.portlet.EventResponse;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.ResourceRequest;
import javax.portlet.ResourceResponse;

import com.vaadin.Application;
import com.vaadin.addon.ipcforliferay.LiferayIPC;
import com.vaadin.addon.ipcforliferay.event.LiferayIPCEvent;
import com.vaadin.addon.ipcforliferay.event.LiferayIPCEventListener;
import com.vaadin.terminal.gwt.server.PortletApplicationContext2.PortletListener;
import com.vaadin.ui.Label;
import com.vaadin.ui.Window;

   public class receiveripc extends Application implements PortletListener {



     String name="";
     String data = "";
    public void init() {
        Window window = new Window("Vaadin Portlet Application");
        window.setName("sample");
        setMainWindow(window);
        window.addComponent(new Label("Hello Vaadin fgfgfgsgsdg!"));
        name=window.getName().toString();
        LiferayIPC liferayipc = new LiferayIPC();

        liferayipc.setImmediate(false);
        liferayipc.setWidth("200px");
        liferayipc.setHeight("200px");
        liferayipc.getDescription();


        liferayipc.addListener("eventid1", new LiferayIPCEventListener() {
            public void eventReceived(LiferayIPCEvent event)
            {
                // Do something with the message data

                data = event.getEventId();
             //  getMainWindow().

               getWindow(name).showNotification("Received hello: " + data);


          //     printData(window,data);

            }
        });
        window.addComponent(liferayipc);
        window.addComponent(new Label(data+"++++++++++gsdgsdgsdgsd++++++555Hello Vaadin hhfhhdfhdfh!"));
    //    window.addComponent(new Label(data+"++++Hello Vaadin usetttttttttttt!"));
    }

//  public Window getWindow() {
//      // TODO Auto-generated method stub
//       Window window1 = window;
//      return window1;
//  }

    protected void printData(Window window, String data) {
        // TODO Auto-generated method stub 
         window.addComponent(new Label(data + "Hello Vaadin userhghjgjgkjh!"));
    }

    @Override
    public void handleRenderRequest(RenderRequest request,
            RenderResponse response, Window window) {
        // TODO Auto-generated method stub

    }

    @Override
    public void handleActionRequest(ActionRequest request,
            ActionResponse response, Window window) {
        // TODO Auto-generated method stub

    }

    @Override
    public void handleEventRequest(EventRequest request,
            EventResponse response, Window window) {
        // TODO Auto-generated method stub

    }

    @Override
    public void handleResourceRequest(ResourceRequest request,
            ResourceResponse response, Window window) {
        // TODO Auto-generated method stub

    }



//  LiferayIPCEvent event=null;
//  event.getData();
//  LiferayIPCEventListener listener=null;
//  listener.eventReceived(event);

}