public void onEvent(Event<UICategoryForm> event, UICategoryForm categoryForm, String objectId) throws Exception { ; String[] objects = objectId.split(ForumUtils.COMMA); String type = objects[0]; String param = objects[1]; UIPopupContainer popupContainer = categoryForm.getAncestorOfType(UIPopupContainer.class); UIUserSelect uiUserSelect = popupContainer.findFirstComponentOfType(UIUserSelect.class); if (uiUserSelect != null) { UIPopupWindow popupWindow = uiUserSelect.getParent(); closePopupWindow(popupWindow); } UIGroupSelector uiGroupSelector = null; if (type.equals(UIGroupSelector.TYPE_MEMBERSHIP)) { uiGroupSelector = openPopup(popupContainer, UIGroupSelector.class, "UIMemberShipSelector", 600, 0); } else if (type.equals(UIGroupSelector.TYPE_GROUP)) { uiGroupSelector = openPopup(popupContainer, UIGroupSelector.class, "GroupSelector", 600, 0); } uiGroupSelector.getAncestorOfType(UIPopupWindow.class).setRendered(true); uiGroupSelector.setType(type); uiGroupSelector.setSpaceGroupId( categoryForm.getAncestorOfType(UIForumPortlet.class).getSpaceGroupId()); uiGroupSelector.setComponent(categoryForm, new String[] {param}); uiGroupSelector.getChild(UITree.class).setId(UIGroupSelector.TREE_GROUP_ID); uiGroupSelector .getChild(org.exoplatform.webui.core.UIBreadcumbs.class) .setId(UIGroupSelector.BREADCUMB_GROUP_ID); }
public void execute(Event<UICategoryForm> event) throws Exception { UICategoryForm categoryForm = event.getSource(); String id = event .getRequestContext() .getRequestParameter(OBJECTID) .replace("0,", ForumUtils.EMPTY_STR); UIPopupContainer uiPopupContainer = categoryForm.getAncestorOfType(UIPopupContainer.class); categoryForm.showUIUserSelect(uiPopupContainer, USER_SELECTOR_POPUPWINDOW, id); event.getRequestContext().addUIComponentToUpdateByAjax(uiPopupContainer); }
public void onEvent(Event<UICategoryForm> event, UICategoryForm uiForm, String id) throws Exception { uiForm.id = Integer.parseInt(id); UIPopupWindow popupWindow = uiForm.getAncestorOfType(UIPopupWindow.class); if (uiForm.id == 1) { popupWindow.setWindowSize(550, 440); } else { popupWindow.setWindowSize(550, 380); } Util.getPortalRequestContext().setResponseComplete(true); }
public void execute(Event<UIUserSelect> event) throws Exception { UIUserSelect uiUserSelector = event.getSource(); String values = uiUserSelector.getSelectedUsers(); UIForumPortlet forumPortlet = uiUserSelector.getAncestorOfType(UIForumPortlet.class); UICategoryForm categoryForm = forumPortlet.findFirstComponentOfType(UICategoryForm.class); UIPopupWindow popupWindow = uiUserSelector.getParent(); String id = uiUserSelector.getPermisionType(); if (id.equals(FIELD_USERPRIVATE_MULTIVALUE)) { UIFormInputWithActions catDetail = categoryForm.getChildById(CATEGORY_DETAIL_TAB); categoryForm.setValueField(catDetail, FIELD_USERPRIVATE_MULTIVALUE, values); } closePopupWindow(popupWindow); event.getRequestContext().addUIComponentToUpdateByAjax(categoryForm); }
public void onEvent(Event<UICategoryForm> event, UICategoryForm uiForm, String objectId) throws Exception { if (uiForm.isDoubleClickSubmit) return; String categoryTitle = uiForm.getUIStringInput(FIELD_CATEGORYTITLE_INPUT).getValue(); int maxText = ForumUtils.MAXTITLE; if (categoryTitle.length() > maxText) { warning( "NameValidator.msg.warning-long-text", new String[] {uiForm.getLabel(FIELD_CATEGORYTITLE_INPUT), String.valueOf(maxText)}); return; } categoryTitle = CommonUtils.encodeSpecialCharInTitle(categoryTitle); String description = uiForm.getUIFormTextAreaInput(FIELD_DESCRIPTION_INPUT).getValue(); if (!ForumUtils.isEmpty(description) && description.length() > maxText) { warning( "NameValidator.msg.warning-long-text", new String[] {uiForm.getLabel(FIELD_DESCRIPTION_INPUT), String.valueOf(maxText)}); return; } description = CommonUtils.encodeSpecialCharInTitle(description); String categoryOrder = uiForm.getUIStringInput(FIELD_CATEGORYORDER_INPUT).getValue(); if (ForumUtils.isEmpty(categoryOrder)) categoryOrder = "0"; categoryOrder = ForumUtils.removeZeroFirstNumber(categoryOrder); if (categoryOrder.length() > 3) { warning( "NameValidator.msg.erro-large-number", new String[] {uiForm.getLabel(FIELD_CATEGORYORDER_INPUT)}); return; } UIPermissionPanel permissionTab = uiForm.getChildById(PERMISSION_TAB); String moderator = permissionTab.getOwnersByPermission(MODERAROR); moderator = ForumUtils.removeSpaceInString(moderator); moderator = ForumUtils.removeStringResemble(moderator); String[] moderators = ForumUtils.splitForForum(moderator); if (!ForumUtils.isEmpty(moderator)) { String erroUser = UserHelper.checkValueUser(moderator); if (!ForumUtils.isEmpty(erroUser)) { warning( "NameValidator.msg.erroUser-input", new String[] {uiForm.getLabel(MODERAROR), erroUser}); return; } } else { moderators = new String[] {""}; } String userPrivate = uiForm.getUIFormTextAreaInput(FIELD_USERPRIVATE_MULTIVALUE).getValue(); if (!ForumUtils.isEmpty(userPrivate) && !ForumUtils.isEmpty(moderator)) { userPrivate = userPrivate + ForumUtils.COMMA + moderator; } userPrivate = ForumUtils.removeSpaceInString(userPrivate); userPrivate = ForumUtils.removeStringResemble(userPrivate); String[] userPrivates = ForumUtils.splitForForum(userPrivate); if (!ForumUtils.isEmpty(userPrivate)) { String erroUser = UserHelper.checkValueUser(userPrivate); if (!ForumUtils.isEmpty(erroUser)) { warning( "NameValidator.msg.erroUser-input", new String[] {uiForm.getLabel(FIELD_USERPRIVATE_MULTIVALUE), erroUser}); return; } } else { userPrivates = new String[] {""}; } String topicable = permissionTab.getOwnersByPermission(TOPICABLE); String postable = permissionTab.getOwnersByPermission(POSTABLE); String viewer = permissionTab.getOwnersByPermission(VIEWER); topicable = ForumUtils.removeSpaceInString(topicable); postable = ForumUtils.removeSpaceInString(postable); viewer = ForumUtils.removeSpaceInString(viewer); String erroUser = UserHelper.checkValueUser(topicable); erroUser = UserHelper.checkValueUser(topicable); if (!ForumUtils.isEmpty(erroUser)) { warning( "NameValidator.msg.erroUser-input", new String[] {uiForm.getLabel(TOPICABLE), erroUser}); return; } erroUser = UserHelper.checkValueUser(postable); if (!ForumUtils.isEmpty(erroUser)) { warning( "NameValidator.msg.erroUser-input", new String[] {uiForm.getLabel(POSTABLE), erroUser}); return; } erroUser = UserHelper.checkValueUser(viewer); if (!ForumUtils.isEmpty(erroUser)) { warning( "NameValidator.msg.erroUser-input", new String[] {uiForm.getLabel(VIEWER), erroUser}); return; } String[] setTopicable = ForumUtils.splitForForum(topicable); String[] setPostable = ForumUtils.splitForForum(postable); String[] setViewer = ForumUtils.splitForForum(viewer); String userName = uiForm.getUserProfile().getUserId(); UIForumPortlet forumPortlet = uiForm.getAncestorOfType(UIForumPortlet.class); boolean isNew = true; Category cat = new Category(); if (!ForumUtils.isEmpty(uiForm.categoryId)) { cat = uiForm.getForumService().getCategory(uiForm.categoryId); if (cat == null) { warning("UIForumPortlet.msg.catagory-deleted", false); forumPortlet.cancelAction(); forumPortlet.renderForumHome(); event.getRequestContext().addUIComponentToUpdateByAjax(forumPortlet); return; } isNew = false; } cat.setOwner(userName); cat.setCategoryName(categoryTitle.trim()); cat.setCategoryOrder(Long.parseLong(categoryOrder)); cat.setCreatedDate(new Date()); cat.setDescription(description); cat.setModifiedBy(userName); cat.setModifiedDate(new Date()); cat.setUserPrivate(userPrivates); cat.setModerators(moderators); cat.setCreateTopicRole(setTopicable); cat.setPoster(setPostable); cat.setViewer(setViewer); UICategoryContainer categoryContainer = forumPortlet.getChild(UICategoryContainer.class); try { uiForm.getForumService().saveCategory(cat, isNew); List<String> invisibleCategories = forumPortlet.getInvisibleCategories(); if (!invisibleCategories.isEmpty()) { List<String> invisibleForums = forumPortlet.getInvisibleForums(); invisibleCategories.add(cat.getId()); String listForumId = UICategoryForm.listToString(invisibleForums); String listCategoryId = UICategoryForm.listToString(invisibleCategories); ForumUtils.savePortletPreference(listCategoryId, listForumId); forumPortlet.loadPreferences(); } UICategory uiCategory = categoryContainer.getChild(UICategory.class); uiCategory.setIsEditForum(true); uiCategory.updateByBreadcumbs(cat.getId()); categoryContainer.updateIsRender(false); forumPortlet.updateIsRendered(ForumUtils.CATEGORIES); forumPortlet.findFirstComponentOfType(UIBreadcumbs.class).setUpdataPath(cat.getId()); } catch (Exception e) { warning("UIForumPortlet.msg.catagory-deleted", false); forumPortlet.renderForumHome(); } forumPortlet.cancelAction(); uiForm.isDoubleClickSubmit = true; event.getRequestContext().addUIComponentToUpdateByAjax(forumPortlet); }