static public class SaveActionListener extends EventListener<UICategorySelector>
{
public void execute(Event<UICategorySelector> event) throws Exception
{
UICategorySelector selector = event.getSource();
ApplicationRegistryService appRegService = selector.getApplicationComponent(ApplicationRegistryService.class);
List<ApplicationCategory> categories = appRegService.getApplicationCategories();
categories = categories != null ? categories : new ArrayList<ApplicationCategory>();
UIFormCheckBoxInput<Boolean> chkInput;
for (ApplicationCategory category : categories)
{
chkInput = selector.getUIInput("category_" + category.getName());
if (chkInput != null && chkInput.isChecked())
{
Application newApp = cloneApplication(selector.getApplication());
UIApplicationRegistryPortlet.setPermissionToEveryone(newApp);
appRegService.save(category, newApp);
}
}
UIContainer appInfo = selector.getParent();
appInfo.getChild(UICategorySelector.class).setRendered(false);
UIApplicationRegistryPortlet uiPortlet = appInfo.getAncestorOfType(UIApplicationRegistryPortlet.class);