}
String applicationId = event.getRequestContext().getRequestParameter(UIComponent.OBJECTID);
Application application = event.getSource().getApplication(applicationId);
ApplicationType appType = application.getType();
String portletName = application.getApplicationName();
// String appGroup = application.getApplicationGroup();
// TODO review windowId for eXoWidget and eXoApplication
UIComponent component = null;
if (ApplicationType.GADGET.equals(appType))
{
UIGadget uiGadget = uiPage.createUIComponent(event.getRequestContext(), UIGadget.class, null, null);
uiGadget.setState(new TransientApplicationState<Gadget>(portletName));
// Set Properties For gadget
int posX = (int)(Math.random() * 400);
int posY = (int)(Math.random() * 200);
uiGadget.getProperties().put(UIApplication.locationX, String.valueOf(posX));
uiGadget.getProperties().put(UIApplication.locationY, String.valueOf(posY));
component = uiGadget;
}
else
{
boolean remote = ApplicationType.WSRP_PORTLET.equals(appType);
UIPortlet uiPortlet = uiPage.createUIComponent(UIPortlet.class, null, null);
CloneApplicationState appState;
Object appId;
if (!remote)
{
appState = new CloneApplicationState<Portlet>(application.getId());
}
else
{
appState = new CloneApplicationState<WSRPState>(application.getId());
}
ApplicationType applicationType = remote ? ApplicationType.WSRP_PORTLET : ApplicationType.PORTLET;
PortletState portletState = new PortletState(appState, applicationType);
uiPortlet.setState(portletState);
uiPortlet.setPortletInPortal(false);