From: <jbo...@li...> - 2006-05-16 19:31:36
|
Author: soh...@jb... Date: 2006-05-16 15:31:20 -0400 (Tue, 16 May 2006) New Revision: 4251 Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml Log: http://jira.jboss.com/jira/browse/JBFORUMS-56 - Create a Forum 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-16 19:17:15 UTC (rev 4250) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java 2006-05-16 19:31:20 UTC (rev 4251) @@ -23,6 +23,8 @@ import org.jboss.portlet.forums.ui.*; +import org.jboss.portlet.forums.model.Category; +import org.jboss.portlet.forums.model.Forum; import org.jboss.portlet.forums.model.Topic; import org.jboss.portlet.forums.model.Poll; import org.jboss.portlet.forums.model.PollOption; @@ -37,26 +39,61 @@ public class AdminController extends ActionController { /** - * + * ui data associated with "Category" information * */ - private String newCategory = null; //this is populated when a new category is to be created + private String categoryName = null; + /** + * ui data associated with "Forum" information + * + */ + private String forumName = null; + private String forumDescription = null; + //-----ui data------------------------------------------------------------------------------------------------------------------------- /** - * @return Returns the newCategory. + * @return Returns the categoryName. */ - public String getNewCategory() + public String getCategoryName() { - return newCategory; + return categoryName; } /** - * @param newCategory The newCategory to set. + * @param categoryName The categoryName to set. */ - public void setNewCategory(String newCategory) + public void setCategoryName(String categoryName) { - this.newCategory = newCategory; + this.categoryName = categoryName; } + /** + * @return Returns the forumDescription. + */ + public String getForumDescription() + { + return forumDescription; + } + /** + * @param forumDescription The forumDescription to set. + */ + public void setForumDescription(String forumDescription) + { + this.forumDescription = forumDescription; + } + /** + * @return Returns the forumName. + */ + public String getForumName() + { + return forumName; + } + /** + * @param forumName The forumName to set. + */ + public void setForumName(String forumName) + { + this.forumName = forumName; + } //------------------------------------------------------------------------------------------------------------------------------------- /** * @@ -77,8 +114,8 @@ boolean success = false; try { - BaseController.getForumsModule().createCategory(this.newCategory); - JSFUtil.setMessage(Constants.FEEDBACK,"The Category \""+this.newCategory+"\" was successfully created."); + BaseController.getForumsModule().createCategory(this.categoryName); + JSFUtil.setMessage(Constants.FEEDBACK,"The Category \""+this.categoryName+"\" was successfully created."); success = true; } catch(Exception e) @@ -90,9 +127,50 @@ if(success) { //cleanup the state - this.newCategory = null; + this.categoryName = null; } } return navState; - } + } + + /** + * adds a new forum + * + */ + public String addForum() + { + String navState = null; + boolean success = false; + try + { + //get the categoryId where this forum should be added + int categoryId = -1; + String cour = ForumUtil.getParameter(Constants.p_categoryId); + if(cour!=null && cour.trim().length()>0) + { + categoryId = Integer.parseInt(cour); + } + + //add this new forum to the category + Category category = BaseController.getForumsModule().findCategoryById(new Integer(categoryId)); + BaseController.getForumsModule().createForum(category,this.forumName,this.forumDescription); + + JSFUtil.setMessage(Constants.FEEDBACK,"The Forum \""+this.forumName+"\" was successfully created."); + success = true; + } + catch(Exception e) + { + JSFUtil.handleException(e); + } + finally + { + if(success) + { + //cleanup the state + this.forumName = null; + this.forumDescription = null; + } + } + return navState; + } } 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-16 19:17:15 UTC (rev 4250) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml 2006-05-16 19:31:20 UTC (rev 4251) @@ -41,7 +41,6 @@ <p>${resource.Forum_admin_explain}</p> <!-- Forum admin widget with the list of category and forums in each category --> - <h:form> <table width="100%" cellpadding="4" cellspacing="1" border="0" class="forumline" align="center"> <tr> <th class="thHead" colspan="7">${resource.Forum_admin}</th> @@ -114,13 +113,16 @@ </td> </tr> </c:forEach> - <!-- create new forum widget for each category --> + <!-- create new forum widget for each category --> + <h:form> <tr> <td colspan="7" class="row2"> - <input class="post" type="text" name="forumname_1"/> - <input type="submit" class="liteoption" name="addforum_1" value="${resource.Create_forum}"/> + <input type="hidden" name="c" value="#{category.id}"/> + <h:inputText styleClass="post" value="#{adminController.forumName}" required="true"/> + <h:commandButton styleClass="liteoption" value="${resource.Create_forum}" action="#{adminController.addForum}"/> </td> </tr> + </h:form> <tr> <td colspan="7" height="1" class="spaceRow"> <img src="/subSilver/images/spacer.gif" alt="" width="1" height="1"/> @@ -129,15 +131,16 @@ </c:forEach> <!-- Add new category widget --> + <h:form> <tr> <td colspan="7" class="catBottom"> - <h:inputText id="Category" styleClass="post" value="#{adminController.newCategory}" required="true"/> + <h:inputText id="Category" styleClass="post" value="#{adminController.categoryName}" required="true"/> <h:commandButton styleClass="liteoption" value="${resource.Create_category}" action="#{adminController.addCategory}"/> &nbsp;<h:message for="Category" style="color:red" styleClass="liteoption"/>&nbsp; </td> - </tr> - </table> - </h:form> + </tr> + </h:form> + </table> <!-- integrate the jump box --> <table cellspacing="0" cellpadding="0" border="0" align="right"> |