public void setValues(final UIPortlet uiPortlet) throws Exception { uiPortlet_ = uiPortlet; invokeGetBindingBean(uiPortlet_); String icon = uiPortlet.getIcon(); if (icon == null || icon.length() < 0) { icon = "PortletIcon"; } getChild(UIFormInputIconSelector.class).setSelectedIcon(icon); getChild(UIFormInputThemeSelector.class) .getChild(UIItemThemeSelector.class) .setSelectedTheme(uiPortlet.getSuitedTheme(null)); if (hasEditMode()) { uiPortlet.setCurrentPortletMode(PortletMode.EDIT); } else { Map<String, String> portletPreferenceMaps = new HashMap<String, String>(); org.gatein.pc.api.Portlet portlet = uiPortlet.getProducedOfferedPortlet(); Set<String> keySet = portlet.getInfo().getPreferences().getKeys(); for (String key : keySet) { PreferenceInfo preferenceInfo = portlet.getInfo().getPreferences().getPreference(key); if (!preferenceInfo.isReadOnly()) { String ppValue = (preferenceInfo.getDefaultValue().size() > 0) ? preferenceInfo.getDefaultValue().get(0) : ""; portletPreferenceMaps.put(key, ppValue); } } Portlet pp = uiPortlet.getPreferences(); if (pp != null) { for (Preference pref : pp) { if (!pref.isReadOnly()) { portletPreferenceMaps.put( pref.getName(), (pref.getValues().size() > 0) ? pref.getValues().get(0) : ""); } } } if (portletPreferenceMaps.size() > 0) { Set<String> ppKeySet = portletPreferenceMaps.keySet(); UIFormInputSet uiPortletPrefSet = getChildById(FIELD_PORTLET_PREF); uiPortletPrefSet.getChildren().clear(); for (String ppKey : ppKeySet) { String ppValue = portletPreferenceMaps.get(ppKey); UIFormStringInput preferenceStringInput = new UIFormStringInput(ppKey, null, ppValue); preferenceStringInput.setLabel(ppKey); preferenceStringInput.addValidator(MandatoryValidator.class); uiPortletPrefSet.addUIFormInput(preferenceStringInput); } uiPortletPrefSet.setRendered(true); setSelectedTab(FIELD_PORTLET_PREF); return; } setSelectedTab("PortletSetting"); } }
public void mapField(UIFormInputSet uiFormInputSet, Object bean) throws Exception { List<UIComponent> children = uiFormInputSet.getChildren(); for (UIComponent uichild : children) { if (uichild instanceof UIFormInput) { invokeGetBindingField((UIFormInput) uichild, bean); } } }
public void mapBean(Object bean, UIFormInputSet uiFormInputSet) throws Exception { List<UIComponent> children = uiFormInputSet.getChildren(); for (UIComponent uichild : children) { if (uichild instanceof UIFormInput) { invokeSetBindingField(bean, (UIFormInput) uichild); } } }
public void execute(Event<UIPageForm> event) throws Exception { UIPageForm uiForm = event.getSource(); UIFormSelectBox uiSelectBox = uiForm.getUIFormSelectBox(OWNER_TYPE); String ownerType = uiSelectBox.getValue(); PortalRequestContext prContext = Util.getPortalRequestContext(); UIFormInputSet uiSettingSet = uiForm.getChildById("PageSetting"); uiForm.setSelectedTab("PageSetting"); List<UIComponent> list = uiSettingSet.getChildren(); if (PortalConfig.USER_TYPE.equals(ownerType)) { uiForm.removeChildById("PermissionSetting"); list.remove(2); list.add(2, uiForm.ownerIdInput); uiForm.ownerIdInput.setValue(prContext.getRemoteUser()); } else { if (uiForm.getChildById("PermissionSetting") == null) { uiForm.addUIComponentInput(uiForm.uiPermissionSetting); } if (PortalConfig.PORTAL_TYPE.equals(ownerType)) { list.remove(2); list.add(2, uiForm.ownerIdInput); uiForm.ownerIdInput.setValue(prContext.getPortalOwner()); uiForm .findFirstComponentOfType(UIListPermissionSelector.class) .setValue(Util.getUIPortal().getAccessPermissions()); uiForm .findFirstComponentOfType(UIPermissionSelector.class) .setValue(Util.getUIPortal().getEditPermission()); } else { list.remove(2); list.add(2, uiForm.groupIdSelectBox); String groupIdSelected = uiForm.groupIdSelectBox.getValue(); groupIdSelected = groupIdSelected.startsWith("/") ? groupIdSelected : "/" + groupIdSelected; String permission = "*:" + groupIdSelected; uiForm .findFirstComponentOfType(UIListPermissionSelector.class) .setValue(new String[] {permission}); UserACL userACL = uiForm.getApplicationComponent(UserACL.class); permission = userACL.getMakableMT() + ":" + groupIdSelected; uiForm.findFirstComponentOfType(UIPermissionSelector.class).setValue(permission); } } prContext.addUIComponentToUpdateByAjax(uiForm.getParent()); }