[jboss-svn-commits] JBL Code SVN: r5010 - in labs/jbossforums/trunk/forums/src: main/org/jboss/portlet/forums/ui main/org/jboss/portlet/forums/ui/action resources/portal-forums-war/WEB-INF resources/portal-forums-war/views resources/portal-forums-war/views/common resources/portal-forums-war/views/topics resources/portal-forums-war/views/watches

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jul 11 13:14:24 EDT 2006


Author: sohil.shah at jboss.com
Date: 2006-07-11 13:14:23 -0400 (Tue, 11 Jul 2006)
New Revision: 5010

Added:
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ForumWatchController.java
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/TopicWatchController.java
   labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/watches/
   labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/watches/forumWatch.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/ForumsJSFPortlet.java
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.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
   labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/common/common.xhtml
   labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml
Log:
Finished Forum Watching usecases - http://jira.jboss.com/jira/browse/JBFORUMS-47

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-07-11 15:53:24 UTC (rev 5009)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/Constants.java	2006-07-11 17:14:23 UTC (rev 5010)
@@ -55,6 +55,7 @@
     public static final String p_vote = "vote";
     public static final String p_results = "results";
     public static final String p_page = "page";
+    public static final String p_watchId = "w";
     //other constants------------------------------------------------------------------------------------------------------------------------------- 
     public static final String QUOTE = "quote";
     public static final String NOTIFY_REPLY_KEY = "notifyreply";
@@ -71,6 +72,16 @@
     public static final String POSTS_TOPIC_KEY = "postspertopic";
     public static final String TOPIC_LOCKED_ERR_KEY = "topiclockederr";
     public static final String BUNDLE_NAME = "ResourceJSF";
+    //---------------------------------------------------------------------------------------------------------------------------------------------
+    /**
+     * When a notification message is sent, send a link to the message.
+     */
+    public static final int WATCH_MODE_LINKED = 0;
+
+    /**
+     * When a notification message is sent, send the message content.
+     */
+    public static final int WATCH_MODE_EMBEDED = 1;
     
     /**
      * DOCUMENT_ME

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java	2006-07-11 15:53:24 UTC (rev 5009)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java	2006-07-11 17:14:23 UTC (rev 5010)
@@ -94,6 +94,7 @@
         String vote = ForumUtil.getParameter(request,Constants.p_vote);
         String results = ForumUtil.getParameter(request,Constants.p_results);
         String page = ForumUtil.getParameter(request,Constants.p_page);
+        String watchId = ForumUtil.getParameter(request,Constants.p_watchId);
         if(categoryId!=null && categoryId.trim().length()>0)
         {
             response.setRenderParameter(Constants.p_categoryId,categoryId);
@@ -142,5 +143,9 @@
         {
             response.setRenderParameter(Constants.p_page,page);
         }
+        if(watchId!=null && watchId.trim().length()>0)
+        {
+            response.setRenderParameter(Constants.p_watchId,watchId);
+        }
     }
 }

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java	2006-07-11 15:53:24 UTC (rev 5009)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java	2006-07-11 17:14:23 UTC (rev 5010)
@@ -71,6 +71,8 @@
 import org.jboss.portlet.forums.impl.PollOptionImpl;
 import org.jboss.portlet.forums.model.Message;
 import org.jboss.portlet.forums.impl.MessageImpl;
+import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.forums.model.Forum;
 
 
 
@@ -452,5 +454,35 @@
         }        
         
         return votePercent;
-    }    
+    } 
+    
+    /**
+     * 
+     *
+     */
+    public static boolean isWatchingTopic(Topic topic)
+    {
+        boolean isWatchingTopic = false;
+        
+        //check if this topic is being watched by the currently logged in user
+        //this is not implemented yet....This will be done
+        //after the JSF refactoring effort. This seems like a new feature and
+        //needs modifications in the Forums Module layer
+        
+        return isWatchingTopic;
+    }
+    
+    /**
+     * 
+     *
+     */
+    public static boolean isWatchingForum(Forum forum)
+    {
+        boolean isWatchingForum = false;
+        
+        //check if this forum is being watched by the currently logged in user
+        
+        
+        return isWatchingForum;
+    }
 }

Added: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ForumWatchController.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ForumWatchController.java	2006-07-11 15:53:24 UTC (rev 5009)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/ForumWatchController.java	2006-07-11 17:14:23 UTC (rev 5010)
@@ -0,0 +1,256 @@
+/*
+* 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 java.util.Collection;
+import java.util.Iterator;
+
+import org.jboss.portlet.forums.ui.*;
+
+import org.jboss.portlet.forums.model.Forum;
+import org.jboss.portlet.forums.impl.ForumImpl;
+import org.jboss.portlet.forums.model.ForumWatch;
+import org.jboss.portlet.forums.impl.ForumWatchImpl;
+
+/**
+ * This controller is used for activating/deactivating/managing forum watches
+ * 
+ * Created on Jul 7, 2006
+ *
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class ForumWatchController extends ActionController 
+{
+    //ui data supporting the AddForumWatch widget
+    private Collection allForums = null;
+    private int selectedForum = 0;
+    private int watchMode = 0;
+    
+    //ui data supporting the update/unwatch widget
+    private Collection forumWatches = null;
+        
+    /**
+     * @return Returns the allForums.
+     */
+    public Collection getAllForums() 
+    {
+        return allForums;
+    }
+    
+    /**
+     * @param allForums The allForums to set.
+     */
+    public void setAllForums(Collection allForums) 
+    {
+        this.allForums = allForums;
+    }
+            
+    /**
+     * @return Returns the selectedForum.
+     */
+    public int getSelectedForum() 
+    {
+        return selectedForum;
+    }
+    
+    /**
+     * @param selectedForum The selectedForum to set.
+     */
+    public void setSelectedForum(int selectedForum) 
+    {
+        this.selectedForum = selectedForum;
+    }
+            
+    /**
+     * @return Returns the watchMode.
+     */
+    public int getWatchMode() 
+    {
+        return watchMode;
+    }
+    
+    /**
+     * @param watchMode The watchMode to set.
+     */
+    public void setWatchMode(int watchMode) 
+    {
+        this.watchMode = watchMode;
+    }
+        
+    /**
+     * @return Returns the forumWatches.
+     */
+    public Collection getForumWatches() 
+    {
+        return forumWatches;
+    }
+    
+    /**
+     * @param forumWatches The forumWatches to set.
+     */
+    public void setForumWatches(Collection forumWatches) 
+    {
+        this.forumWatches = forumWatches;
+    }
+    
+    /**
+     * 
+     *
+     */
+    public boolean isWatchAvailable()
+    {
+        boolean isWatchAvailable = false;
+        int watchCount = 0;
+        if(this.forumWatches!=null)
+        {
+            watchCount = this.forumWatches.size();
+        }
+        if(watchCount>0)
+        {
+            isWatchAvailable = true;
+        }
+        return isWatchAvailable;
+    }
+    //-------------------------------------------------------------------------------------------------------------------------------------------------
+    /**
+     * 
+     *
+     */
+    public ForumWatchController()
+    { 
+        try
+        {
+	        //populate all the registered forums in the system
+	        this.allForums = this.getForumsModule().findForums();
+	        
+	        //populate the already setup form watches
+	        this.reloadWatches();	        	        
+        }
+        catch(Exception e)
+        {
+            JSFUtil.handleException(e);
+        }
+    }        
+    //-------------------------------------------------------------------------------------------------------------------------------------------------
+    /**
+     * 
+     *
+     */
+    public String activateWatch()
+    {
+        String navState = null;
+        try
+        {	                
+	        int forumId = this.selectedForum;
+	        
+	        //make sure a watch for this forum is not already issued for this user
+	        boolean isDuplicate = this.isDuplicateWatch(forumId);
+	        if(isDuplicate)
+	        {
+	            return navState;
+	        }
+	        
+	        //get the forum that must be activated for watching
+	        Forum forum = this.getForumsModule().findForumById(new Integer(forumId));
+	        	        
+	        
+	        //activate the watch for the selected forum
+	        this.getForumsModule().createWatch(PortalUtil.getPoster(),forum,this.watchMode);
+	        
+	        //refresh the watched list
+	        this.reloadWatches();
+        }
+        catch(Exception e)
+        {
+            JSFUtil.handleException(e);
+        }
+        return navState;
+    }
+    
+    /**
+     * 
+     *
+     */
+    public String deActivateWatch()
+    {
+        String navState = null;
+        try
+        {
+	        String w = JSFUtil.getRequestParameter(Constants.p_watchId);
+	        int watchId = Integer.parseInt(w);
+	        
+	        this.getForumsModule().removeWatch(this.getForumsModule().findForumWatchById(new Integer(watchId)));
+	        
+	        //refresh the watch list
+	        this.reloadWatches();
+        }
+        catch(Exception e)
+        {
+            JSFUtil.handleException(e);
+        }        
+        return navState;
+    }
+    
+    /**
+     * 
+     *
+     */
+    public String updateWatch()
+    {
+        return null;
+    }
+    
+    //--------------------------------------------------------------------------------------------------------------    
+    /**
+     * 
+     *
+     */
+    private boolean isDuplicateWatch(int forumId)
+    {
+        boolean isDuplicate = false;
+        
+        if(this.forumWatches!=null)
+        {
+            for(Iterator itr=this.forumWatches.iterator();itr.hasNext();)
+            {
+                ForumWatch cour = (ForumWatch)itr.next();
+                if(cour.getForum().getId().intValue()==forumId)
+                {
+                    isDuplicate = true;
+                    break;
+                }
+            }
+        }
+        
+        return isDuplicate;
+    }
+    
+    /**
+     * 
+     *
+     */
+    private void reloadWatches() throws Exception
+    {
+        this.forumWatches = this.getForumsModule().
+        findForumWatchByUser(PortalUtil.getUser());
+    }
+}

Added: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/TopicWatchController.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/TopicWatchController.java	2006-07-11 15:53:24 UTC (rev 5009)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/TopicWatchController.java	2006-07-11 17:14:23 UTC (rev 5010)
@@ -0,0 +1,82 @@
+/*
+* 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 java.util.ArrayList;
+import java.util.Iterator;
+import java.util.Collection;
+
+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;
+
+/**
+ * This controller is used for activating/deactivating topic watches
+ * 
+ * Created on Jul 7, 2006
+ *
+ * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
+ */
+public class TopicWatchController extends ActionController 
+{
+    /**
+     * 
+     *
+     */
+    public TopicWatchController()
+    {        
+    }
+    
+    /**
+     * 
+     *
+     */
+    public String activateWatch()
+    {
+        String navState = null;
+        
+        String t = JSFUtil.getRequestParameter(Constants.p_topicId);
+        int topicId = Integer.parseInt(t);
+        
+        System.out.println("Successfully activated watch for---"+topicId);
+        
+        return navState;
+    }
+    
+    /**
+     * 
+     *
+     */
+    public String deActivateWatch()
+    {
+        String navState = null;
+        
+        String t = JSFUtil.getRequestParameter(Constants.p_topicId);
+        int topicId = Integer.parseInt(t);
+        
+        System.out.println("Successfully deActivated watch for---"+topicId);
+        
+        return navState;
+    }
+}

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-07-11 15:53:24 UTC (rev 5009)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml	2006-07-11 17:14:23 UTC (rev 5010)
@@ -8,11 +8,11 @@
 	<!-- general application configuration -->
 	<application>
 	    <!-- jbossportal-facelets integration -->
-	    <!--property-resolver>org.jboss.portal.faces.el.DelegatingPropertyResolver</property-resolver>
-	    <view-handler>com.sun.facelets.FaceletPortletViewHandler</view-handler-->
+	    <property-resolver>org.jboss.portal.faces.el.DelegatingPropertyResolver</property-resolver>
+	    <view-handler>com.sun.facelets.FaceletPortletViewHandler</view-handler>
 	    
 	    <!-- standalone facelets integration -->
-    	<view-handler>com.sun.facelets.FaceletViewHandler</view-handler> 
+    	<!--view-handler>com.sun.facelets.FaceletViewHandler</view-handler--> 
     	
     	<!-- custom action listener with integrated authorization checking -->
     	<action-listener>org.jboss.portlet.forums.auth.AuthorizationListener</action-listener>
@@ -86,7 +86,15 @@
                             <key>topicSplit</key>
                             <value>/views/moderator/modcp_split.jsf</value>
                         </map-entry>
-                    </map-entries>
+                <map-entry>
+			     <key>forumWatch</key>
+			     <value>/views/watches/forumWatch.jsf</value>
+			    </map-entry>
+			    <map-entry>
+			     <key>admin</key>
+			     <value>/views/admin/index.jsf</value>
+			    </map-entry>
+             </map-entries>                
 	    </managed-property>	    	    
 	</managed-bean>		
 			
@@ -306,7 +314,7 @@
 	  	<managed-bean-name>splitTopic</managed-bean-name>
 	  	<managed-bean-class>org.jboss.portlet.forums.ui.action.SplitTopic</managed-bean-class>
 	  	<managed-bean-scope>session</managed-bean-scope>
-        </managed-bean>
+     </managed-bean>
         
 	 <navigation-rule>
             <from-view-id>/views/moderator/modcp_body.xhtml</from-view-id>
@@ -469,4 +477,30 @@
 	    	</map-entries>
 	    </managed-property> 
 	 </managed-bean>
+	 
+	 <!-- topic watch controller -->
+	 <managed-bean>
+	  	<managed-bean-name>topicWatch</managed-bean-name>
+	  	<managed-bean-class>org.jboss.portlet.forums.ui.action.TopicWatchController</managed-bean-class>
+	  	<managed-bean-scope>request</managed-bean-scope>
+	 </managed-bean>
+	 
+	 <!-- forum watch controller -->
+	 <managed-bean>
+	  	<managed-bean-name>forumWatch</managed-bean-name>
+	  	<managed-bean-class>org.jboss.portlet.forums.ui.action.ForumWatchController</managed-bean-class>
+	  	<managed-bean-scope>request</managed-bean-scope>
+	  	<managed-property>
+	  		<!-- set the default embedded mode -->
+	  		<property-name>watchMode</property-name>
+	  		<value>1</value>
+	  	</managed-property>
+	 </managed-bean>
+	 <navigation-rule>
+         <from-view-id>/views/watches/forumWatch.xhtml</from-view-id>
+            <navigation-case>
+                <from-outcome>updateWatch</from-outcome>
+                <to-view-id>/views/watches/forumWatch.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/WEB-INF/forums.taglib.xml
===================================================================
--- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml	2006-07-11 15:53:24 UTC (rev 5009)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml	2006-07-11 17:14:23 UTC (rev 5010)
@@ -114,6 +114,24 @@
   		<function-signature>java.lang.String getFolderType(org.jboss.portlet.forums.model.Topic)</function-signature>
 	</function>
 	
+	<!-- 
+		 function to get isWatchingTopic
+	-->
+	<function>
+  		<function-name>isWatchingTopic</function-name>
+  		<function-class>org.jboss.portlet.forums.ui.PortalUtil</function-class>
+  		<function-signature>boolean isWatchingTopic(org.jboss.portlet.forums.model.Topic)</function-signature>
+	</function>
+	
+	<!-- 
+		 function to get isWatchingForum
+	-->
+	<function>
+  		<function-name>isWatchingForum</function-name>
+  		<function-class>org.jboss.portlet.forums.ui.PortalUtil</function-class>
+  		<function-signature>boolean isWatchingForum(org.jboss.portlet.forums.model.Forum)</function-signature>
+	</function>
+	
 	<!-- access control tag -->
 	<tag>
 		<tag-name>isAllowed</tag-name>

Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/common/common.xhtml
===================================================================
--- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/common/common.xhtml	2006-07-11 15:53:24 UTC (rev 5009)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/common/common.xhtml	2006-07-11 17:14:23 UTC (rev 5010)
@@ -36,7 +36,35 @@
 	<!-- resourceBundle to be used by this entire application -->
 	<f:loadBundle basename="ResourceJSF" var="resource"/>
 	
-	<!-- header -->
+	<!-- display the function tray -->
+	<div align="center">
+	    <table cellspacing="0" cellpadding="2" border="0">
+   		<tr>
+      	<td align="center" valign="top" nowrap="nowrap">
+      	<span class="mainmenu">&amp;nbsp;&amp;nbsp;      	
+      		<h:outputLink value="#{forums:outputLink(shared.links['category'],true)}" styleClass="mainmenu">
+      			<img src="/portal-forums/subSilver/images/icon_mini_search.gif" width="12" height="13" border="0" alt="Home" hspace="3"/>
+      			Home
+      		</h:outputLink>&amp;nbsp;&amp;nbsp;
+      	</span>
+      	<span class="mainmenu">&amp;nbsp;&amp;nbsp;      	
+      		<h:outputLink value="#{forums:outputLink(shared.links['forumWatch'],true)}" styleClass="mainmenu">
+      			<img src="/portal-forums/subSilver/images/icon_mini_watch.gif" width="12" height="13" border="0" alt="Watched Forums" hspace="3"/>
+      			Watched Forums
+      		</h:outputLink>&amp;nbsp;&amp;nbsp;
+      	</span>
+      	<forums:isAllowed fragment="acl://accessAdminTool">     	  
+	      	<span class="mainmenu">&amp;nbsp;&amp;nbsp;      	     
+	      		<h:outputLink value="#{forums:outputLink(shared.links['admin'],true)}" styleClass="mainmenu">
+	      			<img src="/portal-forums/subSilver/images/icon_mini_admin.gif" width="12" height="13" border="0" alt="Administration" hspace="3"/>
+	      			Administration
+	      		</h:outputLink>&amp;nbsp;&amp;nbsp;
+	      	</span>
+      	</forums:isAllowed>
+      	</td>
+   	   </tr>
+	   </table>
+	</div>
 
 	<!-- body of the page -->
 	<c:choose>

Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml
===================================================================
--- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml	2006-07-11 15:53:24 UTC (rev 5009)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/topics/viewtopic_body.xhtml	2006-07-11 17:14:23 UTC (rev 5010)
@@ -668,23 +668,46 @@
 	      </tr>         
       </c:if>
    </table>
+   
+   <!-- 
+   		integrate topicWatch function here, also make sure this widget is diplayed only when the user is non-anonymous,
+   		this feature is deferred until next forums release. The ForumsModule does not have the necessary functions on it
+   		for it to be part of this refactoring effort
+   -->
+   <!--table width="100%" cellspacing="2" border="0" align="center">
+   		<tr>   			
+         	<td width="40%" valign="top" nowrap="nowrap" align="left">
+            	<span class="gensmall">
+            		<c:choose>
+            			<c:when test="#{forums:isWatchingTopic(topic.topic)}">
+            				<h:commandLink action="#{topicWatch.deActivateWatch}">
+            					<f:param name="t" value="#{topic.topic.id}"/>
+            					<h:outputText>Stop watching this topic for replies</h:outputText>
+            				</h:commandLink>
+            			</c:when>
+            			<c:otherwise>
+            				<h:commandLink action="#{topicWatch.activateWatch}">
+            					<f:param name="t" value="#{topic.topic.id}"/>
+            					<h:outputText>Watch this topic for replies</h:outputText>
+            				</h:commandLink>
+            			</c:otherwise>
+            		</c:choose>
+            	</span>
+            	<br/>
+            	&amp;nbsp;
+            	<br/>
+         	</td>
+   		</tr>
+   </table-->
     
    <table width="100%" cellspacing="2" border="0" align="center">
-      <tr>
-         <!-- TODO: CODE IN FORUMSPORTLET IS COMMENTED OUT PROBABLY THIS NEEDS TO BE REIMPLEMENTED
-         <td width="40%" valign="top" nowrap="nowrap" align="left">
-            <span class="gensmall">${n:out(&quot;S_WATCH_TOPIC&quot;)}</span>
-            <br/>
-            &amp;nbsp;
-            <br/>
-        </td>
-        -->
-                
-        <!-- instant reply widget -->        
-        <forums:isAllowed fragment="acl://reply" contextData="#{topic.topic}">                    
-        <script language='JavaScript' type='text/javascript'>
-        function checkForm() 
-        {        
+      <tr>         
+         <forums:isAllowed fragment="acl://reply" contextData="#{topic.topic}">                                            
+         <td>
+            <!-- instant reply widget -->                	
+        	<script language='JavaScript' type='text/javascript'>
+        	function checkForm() 
+        	{        
 			formErrors = false;    		
 			if (document["post:message"].value.length &amp;lt; 2) 
 			{
@@ -699,9 +722,8 @@
 			{				
 				return true;
 			}
-		}
-        </script>         
-         <td>
+			}
+        	</script>
             <h:form id="post">
                <input type="hidden" name="f" value="#{topic.topic.forum.id}"/>
                <input type="hidden" name="t" value="#{topic.topic.id}"/>
@@ -723,6 +745,7 @@
              </h:form>
             </td>
             </forums:isAllowed>
+            
             <!-- integrate jumpbox here -->
             <td align="right" valign="top" nowrap="nowrap">
                 <ui:include src="/views/jumpbox.xhtml"/>                

Added: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/watches/forumWatch.xhtml
===================================================================
--- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/watches/forumWatch.xhtml	2006-07-11 15:53:24 UTC (rev 5009)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/watches/forumWatch.xhtml	2006-07-11 17:14:23 UTC (rev 5010)
@@ -0,0 +1,129 @@
+<!--
+/*
+* 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>Forum Watches Administration</h1>
+
+<p>Here you can administer your forum watches</p>
+
+<h:form>
+
+<!-- Add Forum Watch widget -->
+<table cellspacing="1" cellpadding="4" border="0" align="center" class="forumline">
+	<tr>
+	  <th class="thHead" colspan="2">Add a forum watch</th>
+	</tr>
+
+	<!-- display a list of all the registered forums -->
+	<tr>
+		<td class="row1" align="center">Forum:</td>
+		<td class="row2" align="center">
+			<h:selectOneMenu value="#{forumWatch.selectedForum}">
+				<f:selectItem itemLabel="" itemValue="0"/>
+				<c:forEach items="#{forumWatch.allForums}" var="forumItem">
+					<f:selectItem itemLabel="${forumItem.name}" itemValue="${forumItem.id}"/>
+				</c:forEach>				
+			</h:selectOneMenu>
+		</td>
+	</tr>
+	<!-- display a list of watch modes that the forum watch should have -->
+	<tr>
+		<td class="row1" align="center">Mode:</td>
+		<td class="row2" align="center">
+			<h:selectOneRadio value="#{forumWatch.watchMode}">
+				<f:selectItem itemLabel="Linked" itemValue="0"/> 
+				<f:selectItem itemLabel="Emdedded" itemValue="1"/> 
+			</h:selectOneRadio>
+		</td>
+	</tr>
+	<!-- button binds to activateWatch functionality -->
+	<tr>
+	  <td class="catBottom" colspan="2" align="center">
+	  	<h:commandButton value="Watch" styleClass="mainoption" action="#{forumWatch.activateWatch}"/>
+	  </td>
+	</tr>
+</table>
+
+<br/>
+
+<c:if test="#{forumWatch.watchAvailable}">
+<input type="hidden" name="w"/>
+<table cellspacing="1" cellpadding="2" border="0" align="center" class="forumline">
+<tr>
+    <td class="cat">Forum</td>
+    <td class="cat">Mode</td>
+    <td class="cat">Action</td>
+</tr>
+
+<c:forEach items="#{forumWatch.forumWatches}" var="watch">
+<tr> 	
+	<!-- forum link -->   
+    <td class="row2" align="center">
+    	<span class="genmed">    		
+    		<h:outputLink value="#{forums:outputLink(shared.links['forum'],true)}" styleClass="genmed">          			
+		    	<f:param name="f" value="#{watch.forum.id}"/>
+		        <h:outputText value="#{watch.forum.name}"/>  					
+		    </h:outputLink>
+    	</span>
+    </td>
+    <!-- mode -->
+    <td class="row2" align="center">
+    	<span class="genmed">    		
+    		<h:selectOneRadio value="#{watch.mode}">
+				<f:selectItem itemLabel="Linked" itemValue="0"/> 
+				<f:selectItem itemLabel="Emdedded" itemValue="1"/> 
+			</h:selectOneRadio>
+    	</span>
+    </td>
+    <!-- actions that can be done on this forum watch -->
+    <td class="row2" align="center">        
+        <h:commandButton value="Unwatch" action="#{forumWatch.deActivateWatch}" onclick="javascript:w.value='#{watch.id}';"/>
+    </td>
+</tr>
+</c:forEach>
+	<!-- button binds to updateWatch functionality -->
+	<tr>
+	  <td class="catBottom" colspan="3" align="center">
+	  	<h:commandButton value="Update" styleClass="mainoption" action="#{forumWatch.updateWatch}"/>
+	  </td>
+	</tr>
+</table>
+</c:if>
+
+</h:form>
+
+</ui:define>
+</ui:composition>
+   
+</div>
\ No newline at end of file




More information about the jboss-svn-commits mailing list