[jboss-svn-commits] JBL Code SVN: r12014 - in labs/jbossforums/branches/forums101P26/forums/src: resources/portal-forums-war/views/topics and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon May 21 09:12:04 EDT 2007


Author: unibrew
Date: 2007-05-21 09:12:04 -0400 (Mon, 21 May 2007)
New Revision: 12014

Modified:
   labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/DeletePost.java
   labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/topics/delete_post.xhtml
Log:
[JBFORUMS-236] Navigation problem with deleting a post solved.

Modified: labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/DeletePost.java
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/DeletePost.java	2007-05-21 13:07:28 UTC (rev 12013)
+++ labs/jbossforums/branches/forums101P26/forums/src/main/org/jboss/portlet/forums/ui/action/DeletePost.java	2007-05-21 13:12:04 UTC (rev 12014)
@@ -38,6 +38,19 @@
  */
 public class DeletePost extends ActionController
 {
+    
+    private int postId;
+    
+    public int getPostId()
+    {
+        return this.postId;
+    }
+    
+    public void setPostId(int postId)
+    {
+        this.postId=postId;
+    }
+    
     //----------------------------------------------------------------------------------------------------------------------------------
     /**
      * 
@@ -45,8 +58,32 @@
      */
     public DeletePost()
     {
-        
+        try
+        {
+            execute();
+        } catch (Exception e)
+        {
+            JSFUtil.handleException(e);
+        }
     }
+    
+    //initialization--------------------------------------------------------------------------------------------------------------------------
+    
+    /**
+     * 
+     */
+    public void execute() throws Exception
+    {
+        //get the post id
+        int postId = -1;
+        String p = ForumUtil.getParameter(Constants.p_postId);
+        if(p!=null && p.trim().length()>0)
+        {
+            postId = Integer.parseInt(p);
+        }
+        this.postId = postId;
+    }
+    
     //actions---------------------------------------------------------------------------------------------------------------------------------
     /**
      * 
@@ -56,13 +93,6 @@
         String navState = null;        
         try
         {
-            //get the post id
-            int postId = -1;
-	        String p = ForumUtil.getParameter(Constants.p_postId);
-	        if(p!=null && p.trim().length()>0)
-	        {
-	            postId = Integer.parseInt(p);
-	        }
 	        
 	        //setup the business objects/data of interest
 	        Post post = BaseController.getForumsModule().findPostById(new Integer(postId));
@@ -96,19 +126,19 @@
 	            // the watches
 	            // the poll
 	            // the links	            
-	            this.getForumsModule().removeTopic(post.getTopic());	 
+	            getForumsModule().removeTopic(post.getTopic());	 
 	            
 	            //set the proper navigation state
 	            navState = Constants.TOPIC_DELETED;
 	         }
 	         else
 	         {	            
-	            this.getForumsModule().removePost(post);
+	            getForumsModule().removePost(post);
 	            topic.setReplies(topic.getReplies() - 1);
 	            forum.setPostCount(forum.getPostCount() - 1);	            
 	            if(isLastPost)
 	            {
-	               Post lastPost = this.getForumsModule().findLastPost(topic);
+	               Post lastPost = getForumsModule().findLastPost(topic);
 	               topic.setLastPostDate(lastPost.getCreateDate());
 	            }
 	            

Modified: labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/topics/delete_post.xhtml
===================================================================
--- labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/topics/delete_post.xhtml	2007-05-21 13:07:28 UTC (rev 12013)
+++ labs/jbossforums/branches/forums101P26/forums/src/resources/portal-forums-war/views/topics/delete_post.xhtml	2007-05-21 13:12:04 UTC (rev 12014)
@@ -45,9 +45,9 @@
 	         	<span class="gen"><br/>
 	         		${resource.Confirm_delete}
 	            <br/><br/>
-	            <input type="hidden" name="p" value="#{param['p']}"/>	            
 	            <input type="hidden" name="t" value="#{param['t']}"/>	            
 	            <input type="hidden" name="f" value="#{param['f']}"/>	            
+                <h:inputHidden name="postId" value="#{deletePost.postId}" />
 	            <h:commandButton type="submit" value="${resource.Yes}" styleClass="mainoption" action="#{deletePost.confirmDelete}"/>
 	            	&#160;&#160;
 	            <h:commandButton type="button" value="${resource.No}" styleClass="liteoption" onclick="javascript:history.back();"/>	            




More information about the jboss-svn-commits mailing list