public void execute(Event<UIAddApplicationForm> event) throws Exception
{
UIAddApplicationForm uiForm = event.getSource();
UIApplicationOrganizer uiOrganizer = uiForm.getParent();
WebuiRequestContext ctx = event.getRequestContext();
ApplicationRegistryService appRegService = uiForm.getApplicationComponent(ApplicationRegistryService.class);
ApplicationCategory selectedCate = uiOrganizer.getSelectedCategory();
if (appRegService.getApplicationCategory(selectedCate.getName()) == null)
{
uiOrganizer.reload();
UIApplication uiApp = ctx.getUIApplication();
uiApp.addMessage(new ApplicationMessage("category.msg.changeNotExist", null));
ctx.addUIComponentToUpdateByAjax(uiOrganizer);
return;
}
UIFormRadioBoxInput uiRadio = uiForm.getUIInput("application");
String displayName = uiForm.getUIStringInput(FIELD_NAME).getValue();
if (uiForm.getApplications().size() == 0)
{
ctx.getUIApplication().addMessage(new ApplicationMessage("UIAddApplicationForm.msg.appNotExists", null));
ctx.addUIComponentToUpdateByAjax(uiOrganizer);
return;
}
Application tmp = uiForm.getApplications().get(Integer.parseInt(uiRadio.getValue()));
// check portet name is exist
if (appRegService.getApplication(selectedCate.getName(), tmp.getApplicationName()) != null)
{
WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
UIApplication uiApp = context.getUIApplication();
uiApp.addMessage(new ApplicationMessage("UIAddApplicationForm.msg.PortletExist", null));
return;
}
Application app = cloneApplication(tmp);