Created
August 11, 2011 14:35
-
-
Save TheRyanBurke/1139809 to your computer and use it in GitHub Desktop.
Vaadin IPC with Liferay add-on
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DevicesPortlet extends Application implements PortletListener{ | |
LiferayIPC liferayIPC = new LiferayIPC(); | |
@Override | |
public void init() { | |
Window mainWindow = new Window("Device Portlet"); | |
setMainWindow(mainWindow); | |
/* | |
* Set listener | |
*/ | |
if (getContext() instanceof PortletApplicationContext2) { | |
((PortletApplicationContext2) getContext()).addPortletListener(this, this); | |
} else { | |
System.out.println("Portlet error"); | |
} | |
} | |
@Override | |
public void handleRenderRequest(RenderRequest request, | |
RenderResponse response, Window window) { | |
if(!window.getComponentIterator().hasNext()) | |
{ | |
VerticalLayout deviceTableContainer = new VerticalLayout(); | |
deviceTableContainer.addComponent(createDeviceTable()); | |
liferayIPC.setImmediate(false); | |
liferayIPC.setWidth("-1px"); | |
liferayIPC.setHeight("-1px"); | |
liferayIPC.addListener("newPerson", new LiferayIPCEventListener() { | |
public void eventReceived(LiferayIPCEvent event) | |
{ | |
log.info("IPC event received!"); | |
} | |
}); | |
deviceTableContainer.addComponent(liferayIPC); | |
window.addComponent(deviceTableContainer); | |
} | |
} | |
} | |
private Table createDeviceTable(String portletEmail, String portletSession) | |
{ | |
Table deviceTable = new Table(); | |
/* ... code to populate Table ... */ | |
ValueChangeListener projectDeviceTableListener = new Table.ValueChangeListener() { | |
public void valueChange(ValueChangeEvent event) { | |
//fire IPC event for other portlets to update | |
liferayIPC.sendEvent("newPerson", "fname;lname;15"); | |
} | |
}; | |
deviceTable.addListener(projectDeviceTableListener); | |
return deviceTable; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment