From: <jbo...@li...> - 2006-05-24 15:01:04
|
Author: soh...@jb... Date: 2006-05-24 11:00:55 -0400 (Wed, 24 May 2006) New Revision: 4405 Added: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/editForum.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/main/org/jboss/portlet/forums/ui/view/ViewAdminPanel.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-58 - Edit Forum 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-24 14:30:17 UTC (rev 4404) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-24 15:00:55 UTC (rev 4405) @@ -38,6 +38,7 @@ public static final String TOPIC_DELETED = "topicDeleted"; public static final String FEEDBACK = "feedback"; public static final String EDIT_CATEGORY = "editCategory"; + public static final String EDIT_FORUM = "editForum"; //---------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-24 14:30:17 UTC (rev 4404) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java 2006-05-24 15:00:55 UTC (rev 4405) @@ -22,6 +22,7 @@ package org.jboss.portlet.forums.ui.action; import java.util.Iterator; +import java.util.Collection; import org.jboss.portlet.forums.ui.*; @@ -51,7 +52,7 @@ */ private String forumName = null; private String forumDescription = null; - + private int forumCategory = 0; //-----ui data------------------------------------------------------------------------------------------------------------------------- /** * @return Returns the categoryName. @@ -95,6 +96,22 @@ { this.forumName = forumName; } + /** + * + * + */ + public int getForumCategory() + { + return this.forumCategory; + } + /** + * + * + */ + public void setForumCategory(int forumCategory) + { + this.forumCategory = forumCategory; + } //------------------------------------------------------------------------------------------------------------------------------------- /** * @@ -105,7 +122,7 @@ try { //load the selected category if a categoryid is found - //fetch the category to be edited + //fetch the category to be edited/deleted int categoryId = -1; String cour = ForumUtil.getParameter(Constants.p_categoryId); if(cour!=null && cour.trim().length()>0) @@ -117,6 +134,22 @@ Category category = BaseController.getForumsModule().findCategoryById(new Integer(categoryId)); this.categoryName = category.getTitle(); } + + //load the selected forum is a forumid is found + //fetch the forum to be edited/deleted + int forumId = -1; + String forumIdStr = ForumUtil.getParameter(Constants.p_forumId); + if(forumIdStr!=null && forumIdStr.trim().length()>0) + { + forumId = Integer.parseInt(forumIdStr); + } + if(forumId!=-1) + { + Forum forum = BaseController.getForumsModule().findForumById(new Integer(forumId)); + this.forumName = forum.getName(); + this.forumDescription = forum.getDescription(); + this.forumCategory = forum.getCategory().getId().intValue(); + } } catch(Exception e) { @@ -233,12 +266,57 @@ } } return navState; - } + } /** * * */ + public String editForum() + { + String navState = null; + boolean success = false; + try + { + int forumId = -1; + String cour = ForumUtil.getParameter(Constants.p_forumId); + if(cour!=null && cour.trim().length()>0) + { + forumId = Integer.parseInt(cour); + } + + //grab the forum from the module and set the proper information + Forum forum = getForumsModule().findForumById(new Integer(forumId)); + Category selectedCategory = getForumsModule().findCategoryById(new Integer(this.forumCategory)); + forum.setCategory(selectedCategory); + forum.setName(this.forumName); + forum.setDescription(this.forumDescription); + + JSFUtil.setMessage(Constants.FEEDBACK,"The Forum \""+this.forumName+"\" was successfully updated."); + navState = Constants.EDIT_FORUM; + success = true; + } + catch(Exception e) + { + JSFUtil.handleException(e); + } + finally + { + if(success) + { + //cleanup the state + this.forumName = null; + this.forumDescription = null; + this.forumCategory = 0; + } + } + return navState; + } + + /** + * + * + */ public String moveCategoryUp() { String navState = null; Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewAdminPanel.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewAdminPanel.java 2006-05-24 14:30:17 UTC (rev 4404) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewAdminPanel.java 2006-05-24 15:00:55 UTC (rev 4405) @@ -22,8 +22,11 @@ package org.jboss.portlet.forums.ui.view; +import java.util.Iterator; import java.util.List; +import org.jboss.portlet.forums.model.Category; +import org.jboss.portlet.forums.model.Forum; import org.jboss.portlet.forums.ui.BaseController; import org.jboss.portlet.forums.ui.Constants; import org.jboss.portlet.forums.ui.ForumUtil; @@ -51,7 +54,8 @@ { try { - return getForumsModule().findCategories(); + List categories = getForumsModule().findCategories(); + return categories; } catch(Exception e) { 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-24 14:30:17 UTC (rev 4404) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-24 15:00:55 UTC (rev 4405) @@ -365,5 +365,12 @@ <from-outcome>editCategory</from-outcome> <to-view-id>/views/admin/index.xhtml</to-view-id> </navigation-case> + </navigation-rule> + <navigation-rule> + <from-view-id>/views/admin/editForum.xhtml</from-view-id> + <navigation-case> + <from-outcome>editForum</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/editForum.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/editForum.xhtml 2006-05-24 14:30:17 UTC (rev 4404) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/editForum.xhtml 2006-05-24 15:00:55 UTC (rev 4405) @@ -0,0 +1,92 @@ +<!-- +/* +* 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_forum}</h1> + + <p>${resource.Forum_edit_delete_explain}</p> + + + <!-- edit forum widget --> + <h:form> + <input type="hidden" name="f" value="#{param['f']}"/> + <table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline" align="center"> + <tr> + <th class="thHead" colspan="2">${resource.Forum_settings}</th> + </tr> + <tr> + <td class="row1">${resource.Forum_name}</td> + <td class="row2"> + <h:inputText id="Forum" size="25" styleClass="post" value="#{adminController.forumName}" required="true"/> + &nbsp;<h:message for="Forum" style="color:red" styleClass="liteoption"/>&nbsp; + </td> + </tr> + <tr> + <td class="row1">${resource.Forum_desc}</td> + <td class="row2"> + <h:inputTextarea rows="5" cols="45" styleClass="post" value="#{adminController.forumDescription}"/> + </td> + </tr> + <tr> + <td class="row1">${resource.Category}</td> + <td class="row2"> + <h:selectOneMenu value="#{adminController.forumCategory}"> + <c:forEach items="#{adminPanel.categories}" var="category"> + <f:selectItem itemValue="#{category.id}" itemLabel="#{category.title}" /> + </c:forEach> + </h:selectOneMenu> + </td> + </tr> + <tr> + <td class="catBottom" colspan="2" align="center"><input type="hidden" name="mode" value="modforum"/> + <h:commandButton value="Update" styleClass="mainoption" action="#{adminController.editForum}"/> + </td> + </tr> + </table> + </h:form> + + <br clear="all"/> + + + <!-- 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-24 14:30:17 UTC (rev 4404) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml 2006-05-24 15:00:55 UTC (rev 4405) @@ -58,7 +58,7 @@ </td> <td class="cat" align="center" valign="middle"> <!-- security check to make sure this link should be displayed or not --> - <forums:isAllowed fragment="acl://editCategory/editLink"> + <forums:isAllowed fragment="acl://editCategory/editLink" contextData="#{category}"> <span class="gen"> <h:outputLink value="#{forums:outputLink('/views/admin/editCategory.jsf',true)}"> <f:param name="c" value="#{category.id}"/> @@ -97,7 +97,7 @@ <span class="gen"> <a href="" target="_new">${forum.name}</a> </span> - <br/><span class="gensmall"></span> + <br/><span class="gensmall">${forum.description}</span> </td> <td class="row1" align="center" valign="middle"> <span class="gen">${forum.topicCount}</span> @@ -106,9 +106,15 @@ <span class="gen">${forum.postCount}</span> </td> <td class="row1" align="center" valign="middle"> - <span class="gen"> - <a href="">${resource.Edit}</a> - </span> + <!-- security check to make sure this link should be displayed or not --> + <forums:isAllowed fragment="acl://editForum/editLink" contextData="#{forum}"> + <span class="gen"> + <h:outputLink value="#{forums:outputLink('/views/admin/editForum.jsf',true)}"> + <f:param name="f" value="#{forum.id}"/> + <h:outputText value="${resource.Edit}"/> + </h:outputLink> + </span> + </forums:isAllowed> </td> <td class="row2" align="center" valign="middle"> <span class="gen"> @@ -166,9 +172,9 @@ <!-- 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> + <td align="right" valign="top" nowrap="nowrap"> + <ui:include src="/views/jumpbox.xhtml"/> + </td> </tr> </table> |