public static class AddNewActionListener extends EventListener<UIPageBrowser> {
public void execute(Event<UIPageBrowser> event) throws Exception {
PortalRequestContext prContext = Util.getPortalRequestContext();
UIPortalApplication uiApp = (UIPortalApplication) prContext.getUIApplication();
UIMaskWorkspace uiMaskWS = uiApp.getChildById(UIPortalApplication.UI_MASK_WS_ID);
boolean hasPermission = false;
String currentUser = prContext.getRemoteUser();
if (currentUser != null) {
UIPageForm uiPageForm = uiMaskWS.createUIComponent(UIPageForm.class, "UIBrowserPageForm", "UIPageForm");
uiPageForm.buildForm(null);
UIFormSelectBox slcOwnerType = uiPageForm.getUIFormSelectBox(UIPageForm.OWNER_TYPE);
List<SelectItemOption<String>> types = slcOwnerType.getOptions();
for (int i = 0; i < types.size(); i++) {
if (PortalConfig.USER_TYPE.equals(types.get(i).getValue())) {
types.remove(types.get(i));
break;
}
}
if (!types.isEmpty()) {
hasPermission = true;
slcOwnerType.setOptions(types);
Event<UIComponent> slcEvent = uiPageForm.createEvent("ChangeOwnerType", Phase.DECODE, event.getRequestContext());
slcEvent.broadcast();
uiMaskWS.setUIComponent(uiPageForm);
uiMaskWS.setShow(true);
prContext.addUIComponentToUpdateByAjax(uiMaskWS);
}
}
if (!hasPermission) {
uiMaskWS.setUIComponent(null);
uiApp.addMessage(new ApplicationMessage("UIPortalManagement.msg.Invalid-CreatePage-Permission", null));
}
}