From: <jbo...@li...> - 2006-05-16 18:27:08
|
Author: soh...@jb... Date: 2006-05-16 14:27:02 -0400 (Tue, 16 May 2006) New Revision: 4249 Added: 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/views/admin/ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.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/JSFUtil.java 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.taglib.xml Log: http://jira.jboss.com/jira/browse/JBFORUMS-55 - Create New 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-16 15:45:55 UTC (rev 4248) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java 2006-05-16 18:27:02 UTC (rev 4249) @@ -36,6 +36,7 @@ public static final String START_NEW_TOPIC = "startNewTopic"; public static final String START_EDIT_POST = "startEditPost"; public static final String TOPIC_DELETED = "topicDeleted"; + public static final String FEEDBACK = "feedback"; //---------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/JSFUtil.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java 2006-05-16 15:45:55 UTC (rev 4248) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java 2006-05-16 18:27:02 UTC (rev 4249) @@ -174,5 +174,40 @@ } return errorMsg; - } + } + + /** + * + * + */ + public static void setMessage(String id,String msg) + { + FacesMessage message = new FacesMessage( + FacesMessage.SEVERITY_INFO,//severity + msg,//summary + msg//detail + ); + FacesContext.getCurrentInstance().addMessage(id,message); + } + + /** + * + * + */ + public static String getMessage(String id) + { + String msg = null; + + Iterator msgs = FacesContext.getCurrentInstance().getMessages(id); + if(msgs!=null) + { + if(msgs.hasNext()) + { + FacesMessage message = (FacesMessage)msgs.next(); + msg = message.getDetail(); + } + } + + return msg; + } } Added: 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 15:45:55 UTC (rev 4248) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java 2006-05-16 18:27:02 UTC (rev 4249) @@ -0,0 +1,98 @@ +/* +* 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. +*/ +package org.jboss.portlet.forums.ui.action; + +import org.jboss.portlet.forums.ui.*; + +import org.jboss.portlet.forums.model.Topic; +import org.jboss.portlet.forums.model.Poll; +import org.jboss.portlet.forums.model.PollOption; +import org.jboss.portlet.forums.model.Poster; + +/** + * + * Created on May 16, 2006 + * + * @author <a href="mailto:soh...@jb...">Sohil Shah</a> + */ +public class AdminController extends ActionController +{ + /** + * + * + */ + private String newCategory = null; //this is populated when a new category is to be created + + //-----ui data------------------------------------------------------------------------------------------------------------------------- + /** + * @return Returns the newCategory. + */ + public String getNewCategory() + { + return newCategory; + } + /** + * @param newCategory The newCategory to set. + */ + public void setNewCategory(String newCategory) + { + this.newCategory = newCategory; + } + //------------------------------------------------------------------------------------------------------------------------------------- + /** + * + * + */ + public AdminController() + { + } + + //----actions--------------------------------------------------------------------------------------------------------------------------- + /** + * adds a category + * + */ + public String addCategory() + { + String navState = null; + boolean success = false; + try + { + BaseController.getForumsModule().createCategory(this.newCategory); + JSFUtil.setMessage(Constants.FEEDBACK,"The Category \""+this.newCategory+"\" was successfully created."); + success = true; + } + catch(Exception e) + { + JSFUtil.handleException(e); + } + finally + { + if(success) + { + //cleanup the state + this.newCategory = null; + } + } + return navState; + } +} Added: 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-16 15:45:55 UTC (rev 4248) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewAdminPanel.java 2006-05-16 18:27:02 UTC (rev 4249) @@ -0,0 +1,62 @@ +/* +* 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. +*/ + +package org.jboss.portlet.forums.ui.view; + +import java.util.List; + +import org.jboss.portlet.forums.ui.BaseController; +import org.jboss.portlet.forums.ui.Constants; +import org.jboss.portlet.forums.ui.ForumUtil; +import org.jboss.portlet.forums.ui.JSFUtil; + +/** + * @author <a href="mailto:soh...@jb...">Sohil Shah</a> + */ +public class ViewAdminPanel extends BaseController +{ + + /** + * + */ + public ViewAdminPanel() + { + super(); + } + + /** + * + * + */ + public List getCategories() + { + try + { + return getForumsModule().findCategories(); + } + catch(Exception e) + { + JSFUtil.handleException(e); + } + return null ; + } +} 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-16 15:45:55 UTC (rev 4248) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-16 18:27:02 UTC (rev 4249) @@ -335,4 +335,20 @@ <managed-bean-class>org.jboss.portlet.forums.ui.action.PollController</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> + + <!-- managedBean for the adminPanel usecase --> + <managed-bean> + <managed-bean-name>adminPanel</managed-bean-name> + <managed-bean-class>org.jboss.portlet.forums.ui.view.ViewAdminPanel</managed-bean-class> + <managed-bean-scope>request</managed-bean-scope> + </managed-bean> + <!-- managedBean for the adminController usecase --> + <managed-bean> + <managed-bean-name>adminController</managed-bean-name> + <managed-bean-class>org.jboss.portlet.forums.ui.action.AdminController</managed-bean-class> + <managed-bean-scope>request</managed-bean-scope> + </managed-bean> + <navigation-rule> + <from-view-id>/views/admin/index.xhtml</from-view-id> + </navigation-rule> </faces-config> \ No newline at end of file Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml 2006-05-16 15:45:55 UTC (rev 4248) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml 2006-05-16 18:27:02 UTC (rev 4249) @@ -44,7 +44,15 @@ <function-class>org.jboss.portlet.forums.ui.JSFUtil</function-class> <function-signature>java.lang.String getErrorMsg()</function-signature> </function> - + <!-- + function retrieves a message if one is found + return null if nothing is found + --> + <function> + <function-name>message</function-name> + <function-class>org.jboss.portlet.forums.ui.JSFUtil</function-class> + <function-signature>java.lang.String getMessage(java.lang.String)</function-signature> + </function> <!-- --> <function> Added: 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 15:45:55 UTC (rev 4248) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/admin/index.xhtml 2006-05-16 18:27:02 UTC (rev 4249) @@ -0,0 +1,153 @@ +<!-- +/* +* 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"> + + <!-- Forum admin tool title/messages --> + <h1>${resource.Forum_admin}</h1> + + <!-- display any feedback messages here --> + <span style="color:green"><b>#{forums:message('feedback')}</b></span><br/> + + <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> + </tr> + + <!-- display a list of categories --> + <c:forEach items="#{adminPanel.categories}" var="category"> + <tr> + <td class="catLeft" colspan="3"> + <span class="cattitle"> + <b> + <a href="">${category.title}</a> + </b> + </span> + </td> + <td class="cat" align="center" valign="middle"> + <span class="gen"> + <a href="">${resource.Edit}</a> + </span> + </td> + <td class="cat" align="center" valign="middle"> + <span class="gen"> + <a href="">${resource.Delete}</a> + </span> + </td> + <td class="cat" align="center" valign="middle" nowrap="nowrap"> + <span class="gen"> + <a href="">${resource.Move_up}</a> + <a href="">${resource.Move_down}</a> + </span> + </td> + <td class="catRight" align="center" valign="middle"> + <span class="gen">&nbsp</span> + </td> + </tr> + <!-- display the forums in this category --> + <c:forEach items="#{category.forums}" var="forum"> + <tr> + <td class="row2"> + <span class="gen"> + <a href="" target="_new">${forum.name}</a> + </span> + <br/><span class="gensmall"></span> + </td> + <td class="row1" align="center" valign="middle"> + <span class="gen">${forum.topicCount}</span> + </td> + <td class="row2" align="center" valign="middle"> + <span class="gen">${forum.postCount}</span> + </td> + <td class="row1" align="center" valign="middle"> + <span class="gen"> + <a href="">${resource.Edit}</a> + </span> + </td> + <td class="row2" align="center" valign="middle"> + <span class="gen"> + <a href="">${resource.Delete}</a> + </span> + </td> + <td class="row1" align="center" valign="middle"> + <span class="gen"> + <a href="">${resource.Move_up}</a> + <br/> + <a href="">${resource.Move_down}</a> + </span> + </td> + <td class="row2" align="center" valign="middle"> + <!--span class="gen"><a href="">Resync</a></span--> + </td> + </tr> + </c:forEach> + <!-- create new forum widget for each category --> + <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}"/> + </td> + </tr> + <tr> + <td colspan="7" height="1" class="spaceRow"> + <img src="/subSilver/images/spacer.gif" alt="" width="1" height="1"/> + </td> + </tr> + </c:forEach> + + <!-- Add new category widget --> + <tr> + <td colspan="7" class="catBottom"> + <h:inputText id="Category" styleClass="post" value="#{adminController.newCategory}" 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> + + <!-- 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 |