Author: soh...@jb... Date: 2006-05-17 10:04:15 -0400 (Wed, 17 May 2006) New Revision: 4280 Added: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/editCategory.xhtml Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml Log: http://jira.jboss.com/jira/browse/JBFORUMS-57 - Edit Category Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-17 07:13:17 UTC (rev 4279) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-17 14:04:15 UTC (rev 4280) @@ -37,6 +37,7 @@ public static final String START_EDIT_POST = "startEditPost"; public static final String TOPIC_DELETED = "topicDeleted"; public static final String FEEDBACK = "feedback"; + public static final String EDIT_CATEGORY = "editCategory"; //---------parameter constants-------------------------------------------------------------------------------------------------- public static final String p_categoryId = "c"; public static final String p_forumId = "f"; Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java 2006-05-17 07:13:17 UTC (rev 4279) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java 2006-05-17 14:04:15 UTC (rev 4280) @@ -44,6 +44,7 @@ * */ private String categoryName = null; + private Category category = null; /** * ui data associated with "Forum" information @@ -66,8 +67,22 @@ public void setCategoryName(String categoryName) { this.categoryName = categoryName; - } + } /** + * @return Returns the category. + */ + public Category getCategory() + { + return category; + } + /** + * @param category The category to set. + */ + public void setCategory(Category category) + { + this.category = category; + } + /** * @return Returns the forumDescription. */ public String getForumDescription() @@ -101,7 +116,26 @@ * */ public AdminController() - { + { + try + { + //load the selected category if a categoryid is found + //fetch the category to be edited + int categoryId = -1; + String cour = ForumUtil.getParameter(Constants.p_categoryId); + if(cour!=null && cour.trim().length()>0) + { + categoryId = Integer.parseInt(cour); + } + if(categoryId!=-1) + { + this.category = BaseController.getForumsModule().findCategoryById(new Integer(categoryId)); + } + } + catch(Exception e) + { + JSFUtil.handleException(e); + } } //----actions--------------------------------------------------------------------------------------------------------------------------- @@ -134,7 +168,36 @@ return navState; } + /** + * edit category + */ + public String editCategory() + { + String navState = null; + boolean success = false; + try + { + JSFUtil.setMessage(Constants.FEEDBACK,"The Category \""+this.category.getTitle()+"\" was successfully updated."); + navState = Constants.EDIT_CATEGORY; + success = true; + } + catch(Exception e) + { + JSFUtil.handleException(e); + } + finally + { + if(success) + { + //cleanup the state + this.categoryName = null; + } + } + return navState; + } + + /** * adds a new forum * */ Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-17 07:13:17 UTC (rev 4279) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-17 14:04:15 UTC (rev 4280) @@ -349,6 +349,10 @@ <managed-bean-scope>request</managed-bean-scope> </managed-bean> <navigation-rule> - <from-view-id>/views/admin/index.xhtml</from-view-id> - </navigation-rule> + <from-view-id>/views/admin/editCategory.xhtml</from-view-id> + <navigation-case> + <from-outcome>editCategory</from-outcome> + <to-view-id>/views/admin/index.xhtml</to-view-id> + </navigation-case> + </navigation-rule> </faces-config> \ No newline at end of file Added: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/editCategory.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/editCategory.xhtml 2006-05-17 07:13:17 UTC (rev 4279) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/editCategory.xhtml 2006-05-17 14:04:15 UTC (rev 4280) @@ -0,0 +1,72 @@ +<!-- +/* +* JBoss, Home of Professional Open Source +* Copyright 2005, JBoss Inc., and individual contributors as indicated +* by the @authors tag. See the copyright.txt in the distribution for a +* full listing of individual contributors. +* +* This is free software; you can redistribute it and/or modify it +* under the terms of the GNU Lesser General Public License as +* published by the Free Software Foundation; either version 2.1 of +* the License, or (at your option) any later version. +* +* This software is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this software; if not, write to the Free +* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +* 02110-1301 USA, or see the FSF site: http://www.fsf.org. +*/ +--> + +<div xmlns="http://www.w3.org/1999/xhtml" + xmlns:ui="http://java.sun.com/jsf/facelets" + xmlns:c="http://java.sun.com/jstl/core" + xmlns:h="http://java.sun.com/jsf/html" + xmlns:f="http://java.sun.com/jsf/core" + xmlns:forums="http://www.jboss.com/products/jbossportal/forums" class="bb"> + + <ui:composition template="/views/common/common.xhtml"> + <ui:define name="mainContent"> + + <h1>${resource.Edit_Category}</h1> + + <p>${resource.Edit_Category_explain}</p> + + <!-- display the edit category widget --> + <h:form> + <input type="hidden" name="c" value="#{param['c']}"/> + <table cellpadding="4" cellspacing="1" border="0" class="forumline" align="center"> + <tr> + <th class="thHead" colspan="2">${resource.Edit_Category}</th> + </tr> + <tr> + <td class="row1">${resource.Category}</td> + <td class="row2"> + <h:inputText id="Category" styleClass="post" size="25" value="#{adminController.category.title}" required="true"/> + &nbsp;<h:message for="Category" style="color:red" styleClass="liteoption"/>&nbsp; + </td> + </tr> + <tr> + <td class="catBottom" colspan="2" align="center"> + <h:commandButton value="${resource.Submit}" styleClass="mainoption" action="#{adminController.editCategory}"/> + </td> + </tr> + </table> + </h:form> + + <!-- integrate the jump box --> + <table cellspacing="0" cellpadding="0" border="0" align="right"> + <tr> + <td align="right" valign="top" nowrap="nowrap"> + <ui:include src="/views/jumpbox.xhtml"/> + </td> + </tr> + </table> + + </ui:define> + </ui:composition> +</div> \ No newline at end of file Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml 2006-05-17 07:13:17 UTC (rev 4279) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml 2006-05-17 14:04:15 UTC (rev 4280) @@ -58,7 +58,10 @@ </td> <td class="cat" align="center" valign="middle"> <span class="gen"> - <a href="">${resource.Edit}</a> + <h:outputLink value="#{forums:outputLink('/views/admin/editCategory.jsf',true)}"> + <f:param name="c" value="#{category.id}"/> + <h:outputText value="${resource.Edit}"/> + </h:outputLink> </span> </td> <td class="cat" align="center" valign="middle"> |