2012-10-10 54 views
1

我有一個要求,比如在Liferay中溝通兩個vaadin portlet。 一個portlet使用vaadin樹視圖顯示報告名稱(webi報告)。當單擊樹時,我必須在另一個portlet中打開相應的報告。使用Vaadin Portlet的Liferay 6.1中的Portlet間通信

任何人都可以請建議您的想法,並分享滿足此要求的細節。

Thaks提前。

回答

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); 

}