我有一个需求,比如在 Liferay 中通信两个 vaadin portlet。一个 portlet 带有显示报告名称(webi 报告)的 vaadin 树视图。单击树时,我必须在另一个 portlet 中打开相应的报告。
任何人都可以提出您的想法并分享满足此要求的详细信息。
提前谢谢。
一种直接的解决方案是 Vaadin IPC 插件。在以下位置查看详细信息和示例:http: //vaadin.com/addon/vaadin-ipc-for-liferay
请注意,这需要使用 6.x 版本的 Vaadin。
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);
}