Author: unibrew Date: 2006-05-25 20:40:26 -0400 (Thu, 25 May 2006) New Revision: 4430 Added: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/move_topic.xhtml Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.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/moderator/modcp_body.xhtml Log: [JBFORUMS-50] Working on delete action Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.java =================================================================== --- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.java 2006-05-25 21:11:23 UTC (rev 4429) +++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.java 2006-05-26 00:40:26 UTC (rev 4430) @@ -58,6 +58,8 @@ private Map checkboxes; + private ResourceBundle bundle; + //----------------bean configuration supplied by the forums-config.xml--------------------------------------------------------------------------------------------- @@ -140,43 +142,88 @@ //ui actions supported by this bean---------------------------------------------------------------------------------------------------- - //TODO: STILL NOT FINISHED + //TODO: STILL NOT FINISHED public String deleteTopic () { Iterator it = checkboxes.keySet().iterator(); // This flag checks if there was at least one topic selected boolean isAnySet=false; + + String message=""; + + try { + while (it.hasNext()) + { + Integer topicId = (Integer)it.next(); + boolean value = ((Boolean)checkboxes.get(topicId)).booleanValue(); + if ( value ) isAnySet=true; + + try { + Topic topic = getForumsModule().findTopicById(topicId); + //this.getForumsModule().removeTopic(topic); + } catch(Exception e) + { + message = bundle.getString("ERR_CANNOT_REMOVE_TOPIC"); + FacesContext.getCurrentInstance().addMessage("message", + new FacesMessage(FacesMessage.SEVERITY_ERROR,message,"moderate")); + return ""; + } + } + if (!isAnySet) + { + //message = bundle.getString(""); + FacesContext.getCurrentInstance().addMessage("message", + new FacesMessage(FacesMessage.SEVERITY_WARN,"Hey","ehhh")); + return ""; + } + message = bundle.getString("SUCC_TOPIC_REMOVED"); + FacesContext.getCurrentInstance().addMessage("message", + new FacesMessage(FacesMessage.SEVERITY_INFO,message, "moderate")); + } catch (Exception e) + { + JSFUtil.handleException(e); + } + return ""; + } + + public String moveTopic () + { + return ""; + } + + //TODO: STILL NOT FINISHED + public String lockTopic () + { + Iterator it = checkboxes.keySet().iterator(); + + // This flag checks if there was at least one topic selected + boolean isAnySet=false; while (it.hasNext()) { Integer topicId = (Integer)it.next(); boolean value = ((Boolean)checkboxes.get(topicId)).booleanValue(); if ( value ) isAnySet=true; - Topic topic = (Topic)forum.getTopics().get(topicId.intValue()); + try { - this.getForumsModule().removeTopic(topic); + Topic topic = getForumsModule().findTopicById(topicId); + //this.getForumsModule().removeTopic(topic); } catch(Exception e) { - JSFUtil.handleException(e); + FacesContext.getCurrentInstance().addMessage("message", + new FacesMessage(FacesMessage.SEVERITY_ERROR,"moderate","ERR_CANNOT_REMOVE_TOPIC")); + return ""; } } - if (!isAnySet) + if (!isAnySet) + { FacesContext.getCurrentInstance().addMessage("message", new FacesMessage(FacesMessage.SEVERITY_WARN,"","ehhh")); + return ""; + } return ""; } - public String moveTopic () - { - return ""; - } - - public String lockTopic () - { - - return ""; - } - public String unlockTopic () { return ""; @@ -184,6 +231,13 @@ private void execute() throws Exception { + // Getting ResourceBundle with current Locale + FacesContext ctx = FacesContext.getCurrentInstance(); + UIViewRoot uiRoot = ctx.getViewRoot(); + Locale locale = uiRoot.getLocale(); + ClassLoader ldr = Thread.currentThread().getContextClassLoader(); + this.bundle = ResourceBundle.getBundle("ResourceJSF", locale, ldr); + int forumId = -1; String f = ForumUtil.getParameter(Constants.p_forumId); if(f!=null && f.trim().length()>0) 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-25 21:11:23 UTC (rev 4429) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml 2006-05-26 00:40:26 UTC (rev 4430) @@ -339,8 +339,26 @@ <navigation-case> <from-outcome>deleteForum</from-outcome> <to-view-id>/views/admin/index.xhtml</to-view-id> - </navigation-case> + </navigation-case> </navigation-rule> + <navigation-rule> + <from-view-id>/views/moderator/modcp_body.xhtml</from-view-id> + <navigation-case> + <from-outcome>delete</from-outcome> + <to-view-id>/views/moderator/delete_topic.xhtml</to-view-id> + </navigation-case> + <navigation-case> + <from-outcome>move</from-outcome> + <to-view-id>/views/moderator/move_topic.xhtml</to-view-id> + </navigation-case> + </navigation-rule> + <navigation-rule> + <from-view-id>/views/moderator/delete_topic.xhtml</from-view-id> + <navigation-case> + <from-outcome>success</from-outcome> + <to-view-id>/views/moderator/modcp_body.xhtml</to-view-id> + </navigation-case> + </navigation-rule> <!-- managedBean for the user preference usecase --> <managed-bean> @@ -416,11 +434,5 @@ <managed-bean-class>org.jboss.portlet.forums.ui.action.DeleteTopic</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> - <navigation-rule> - <from-view-id>/views/moderator/delete_topic.xhtml</from-view-id> - <navigation-case> - <from-action>#{deleteTopic.confirmDelete}</from-action> - <to-view-id>/views/moderator/modcp_body.xhtml</to-view-id> - </navigation-case> - </navigation-rule> + </faces-config> \ No newline at end of file Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_body.xhtml =================================================================== --- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_body.xhtml 2006-05-25 21:11:23 UTC (rev 4429) +++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/modcp_body.xhtml 2006-05-26 00:40:26 UTC (rev 4430) @@ -9,10 +9,6 @@ <ui:composition template="/views/common/common.xhtml"> <ui:define name="mainContent"> -<!-- TODO: -<n:errors/> -<n:success/>--> - <h:messages layout="table" infoStyle="color:green" warnStyle="color:red" /> <h:form> @@ -78,11 +74,11 @@ <tr align="right"> <td class="catBottom" colspan="5" height="29"> - <h:commandButton action="#{moderator.deleteTopic}" class="liteoption" value="${resource.Delete}"> + <h:commandButton action="delete" class="liteoption" value="${resource.Delete}"> <f:param name="f" value="#{forum.forum.id}"/> </h:commandButton> &nbsp; - <h:commandButton action="#{moderator.moveTopic}" class="liteoption" value="${resource.Move}"> + <h:commandButton action="move" class="liteoption" value="${resource.Move}"> <f:param name="f" value="#{forum.forum.id}"/> </h:commandButton> &nbsp; Added: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/moderator/move_topic.xhtml =================================================================== |