[jboss-svn-commits] JBL Code SVN: r5044 - 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/common resources/portal-forums-war/views/pref

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Jul 12 11:54:11 EDT 2006


Author: sohil.shah at jboss.com
Date: 2006-07-12 11:54:09 -0400 (Wed, 12 Jul 2006)
New Revision: 5044

Added:
   labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/common/common_noMenu.xhtml
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/JSFUtil.java
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/PreferenceController.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/WEB-INF/portlet.xml
   labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/common/common.xhtml
   labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/pref/index.xhtml
Log:
Integrated PreferenceManager with the Edit Mode in Portal Environment. Also, made provisions into the function menu when not in standalone environment

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-12 15:05:24 UTC (rev 5043)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java	2006-07-12 15:54:09 UTC (rev 5044)
@@ -22,19 +22,19 @@
 package org.jboss.portlet.forums.ui;
 
 import org.apache.myfaces.portlet.MyFacesGenericPortlet;
-import org.jboss.portlet.JBossRenderRequest;
-import org.jboss.portlet.JBossRenderResponse;
 
 import java.io.IOException;
 
 //portlet api
 import javax.portlet.ActionRequest;
 import javax.portlet.ActionResponse;
-import javax.portlet.PortletRequestDispatcher;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.portlet.PortletException;
+import javax.portlet.PortletSession;
+import javax.portlet.PortletMode;
 
+
 /**
  * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
  *
@@ -65,6 +65,15 @@
     {
         try
         {
+            //make sure this is not a mode change from Edit
+            boolean modeChanged = ((Boolean)request.getAttribute("isPortletModeChanged")).booleanValue();
+            if(modeChanged)
+            {
+                setPortletRequestFlag(request);
+                nonFacesRequest(request,response,"/views/index.jsf");
+                return;
+            }
+            
             super.doView(request,response);
         }
         catch(Throwable t)
@@ -148,4 +157,44 @@
             response.setRenderParameter(Constants.p_watchId,watchId);
         }
     }
+    
+    //integrating handling Edit Mode for handling preferences-----------------------------------------------------------------------------------------------
+    //  override the render() method from GenericPortlet to detect a 
+    //  mode change
+    /**
+     * 
+     */
+    public void render(RenderRequest request, RenderResponse response) 
+    throws PortletException, IOException 
+    {
+	    PortletSession session = request.getPortletSession();
+	    PortletMode mode = (PortletMode)session.getAttribute("CurrentPortletMode");
+	
+	    if (mode == null) 
+	    {
+	       mode = request.getPortletMode();       
+	    }
+	
+	    if (!mode.equals(request.getPortletMode())) 
+	    {
+	       request.setAttribute("isPortletModeChanged", Boolean.TRUE);
+	    } 
+	    else 
+	    {
+	       request.setAttribute("isPortletModeChanged", Boolean.FALSE);
+	    }
+	
+	    session.setAttribute("CurrentPortletMode", request.getPortletMode());
+	    super.render(request, response);
+    }
+    
+    /**
+     * 
+     */
+    protected void doEdit(RenderRequest request, RenderResponse response)
+    throws PortletException, IOException 
+    {        
+        setPortletRequestFlag(request);
+        nonFacesRequest(request,response,"/views/pref/index.jsf");
+    }
 }

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-07-12 15:05:24 UTC (rev 5043)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/JSFUtil.java	2006-07-12 15:54:09 UTC (rev 5044)
@@ -31,6 +31,12 @@
 //logging related
 import org.apache.log4j.Logger;
 
+//servlet import
+import javax.servlet.http.HttpServletRequest;
+
+//portal import
+import javax.portlet.PortletRequest;
+
 //jsf imports
 import javax.faces.application.FacesMessage;
 import javax.faces.context.FacesContext;
@@ -63,7 +69,24 @@
         
         return parameter;
     }
+    
+    /**
+     * 
+     *
+     */
+    public static boolean isRunningInPortal()
+    {
+        boolean isRunningInPortal = false;
         
+        Object request = FacesContext.getCurrentInstance().getExternalContext().getRequest();
+        if(request instanceof PortletRequest)
+        {
+            isRunningInPortal = true;
+        }
+        
+        return isRunningInPortal;
+    }
+        
     /**
      * 
      * 
@@ -248,5 +271,5 @@
         bundleMessage = bundle.getString(messageKey);
         
         return bundleMessage;
-    }
+    }    
 }

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/PreferenceController.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/PreferenceController.java	2006-07-12 15:05:24 UTC (rev 5043)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/PreferenceController.java	2006-07-12 15:54:09 UTC (rev 5044)
@@ -396,7 +396,12 @@
             
             PortalUtil.setPreferences(updated);
             
-            navState = Constants.SUCCESS;
+            //check if this is running as a stanalone app...if thats the case navigate to the proper location
+            if(!JSFUtil.isRunningInPortal())
+            {
+                //
+                navState = Constants.SUCCESS;
+            }
         }
         catch(Exception e)
         {

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-12 15:05:24 UTC (rev 5043)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml	2006-07-12 15:54:09 UTC (rev 5044)
@@ -94,6 +94,10 @@
 			     <key>admin</key>
 			     <value>/views/admin/index.jsf</value>
 			    </map-entry>
+			    <map-entry>
+			     <key>pref</key>
+			     <value>/views/pref/index.jsf</value>
+			    </map-entry>
              </map-entries>                
 	    </managed-property>	    	    
 	</managed-bean>		
@@ -400,14 +404,7 @@
 			<from-outcome>deleteForum</from-outcome>
 			<to-view-id>/views/admin/index.xhtml</to-view-id>
 		</navigation-case>			
-	</navigation-rule>
-        <navigation-rule>
-        <from-view-id>/views/pref/index.xhtml</from-view-id>	
-        <navigation-case>
-			<from-outcome>success</from-outcome>
-			<to-view-id>/views/category/viewcategory_body.xhtml</to-view-id>
-		</navigation-case>			
-	 </navigation-rule>		
+	</navigation-rule>        
                  
          <navigation-rule>
          <from-view-id>/views/moderator/modcp_move.xhtml</from-view-id>
@@ -477,7 +474,15 @@
 	    	</map-entries>
 	    </managed-property> 
 	 </managed-bean>
+	 <navigation-rule>
+        <from-view-id>/views/pref/index.xhtml</from-view-id>	
+        <navigation-case>
+			<from-outcome>success</from-outcome>
+			<to-view-id>/views/index.xhtml</to-view-id>
+		</navigation-case>
+	 </navigation-rule>
 	 
+	 
 	 <!-- topic watch controller -->
 	 <managed-bean>
 	  	<managed-bean-name>topicWatch</managed-bean-name>

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-12 15:05:24 UTC (rev 5043)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums.taglib.xml	2006-07-12 15:54:09 UTC (rev 5044)
@@ -132,6 +132,15 @@
   		<function-signature>boolean isWatchingForum(org.jboss.portlet.forums.model.Forum)</function-signature>
 	</function>
 	
+	<!--
+		function to check if the application is running in a portal envioronment
+	-->
+	<function>
+  		<function-name>isRunningInPortal</function-name>
+  		<function-class>org.jboss.portlet.forums.ui.JSFUtil</function-class>
+  		<function-signature>boolean isRunningInPortal()</function-signature>
+	</function>
+	
 	<!-- access control tag -->
 	<tag>
 		<tag-name>isAllowed</tag-name>

Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/portlet.xml
===================================================================
--- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/portlet.xml	2006-07-12 15:05:24 UTC (rev 5043)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/portlet.xml	2006-07-12 15:54:09 UTC (rev 5044)
@@ -97,6 +97,8 @@
       <expiration-cache>-1</expiration-cache>
       <supports>
          <mime-type>text/html</mime-type>
+         <portlet-mode>VIEW</portlet-mode>
+         <portlet-mode>EDIT</portlet-mode>
       </supports>
       <portlet-info>
          <title>JSF Forums</title>

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-12 15:05:24 UTC (rev 5043)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/common/common.xhtml	2006-07-12 15:54:09 UTC (rev 5044)
@@ -47,12 +47,23 @@
       			Home
       		</h:outputLink>&amp;nbsp;&amp;nbsp;
       	</span>
+      	<c:if test="#{shared.anonymous==false &amp;&amp; forums:isRunningInPortal()==false}">
       	<span class="mainmenu">&amp;nbsp;&amp;nbsp;      	
+      		<h:outputLink value="#{forums:outputLink(shared.links['pref'],true)}" styleClass="mainmenu">
+      			<img src="/portal-forums/subSilver/images/icon_mini_watch.gif" width="12" height="13" border="0" alt="Preferences" hspace="3"/>
+      			Preferences
+      		</h:outputLink>&amp;nbsp;&amp;nbsp;
+      	</span>
+      	</c:if>
+      	<c:if test="#{shared.anonymous==false}">
+      	<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>
+      	</c:if>
+      	<c:if test="#{shared.anonymous==false}">
       	<forums:isAllowed fragment="acl://accessAdminTool">     	  
 	      	<span class="mainmenu">&amp;nbsp;&amp;nbsp;      	     
 	      		<h:outputLink value="#{forums:outputLink(shared.links['admin'],true)}" styleClass="mainmenu">
@@ -61,6 +72,7 @@
 	      		</h:outputLink>&amp;nbsp;&amp;nbsp;
 	      	</span>
       	</forums:isAllowed>
+      	</c:if>
       	</td>
    	   </tr>
 	   </table>

Added: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/common/common_noMenu.xhtml
===================================================================
--- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/common/common_noMenu.xhtml	2006-07-12 15:05:24 UTC (rev 5043)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/common/common_noMenu.xhtml	2006-07-12 15:54:09 UTC (rev 5044)
@@ -0,0 +1,53 @@
+<!--
+/*
+* 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"
+>
+	<!-- stylesheet for this application -->
+	<link rel='stylesheet' type='text/css' href='/portal-forums/subSilver/styles.css' media='screen'/>
+
+	<!-- resourceBundle to be used by this entire application -->
+	<f:loadBundle basename="ResourceJSF" var="resource"/>
+		
+
+	<!-- body of the page -->
+	<c:choose>
+		<c:when test="#{(forums:errorMsg())!=null}">
+			<!-- generic error handling -->
+			<ui:include src="/views/errors/error_body.xhtml"/>
+		</c:when>
+		<c:otherwise>	
+			<!-- main content for this page -->
+			<ui:insert name="mainContent"/>
+		</c:otherwise>
+	</c:choose>
+	
+	<!-- footer -->
+</div>
\ No newline at end of file

Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/pref/index.xhtml
===================================================================
--- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/pref/index.xhtml	2006-07-12 15:05:24 UTC (rev 5043)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/views/pref/index.xhtml	2006-07-12 15:54:09 UTC (rev 5044)
@@ -28,11 +28,12 @@
      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:composition template="/views/common/common_noMenu.xhtml">
+   
    <ui:define name="mainContent">
    
-    <c:if test="#{prefController.initialized}">
+    <c:if test="#{prefController.initialized &amp;&amp; prefController.anonymous==false}">
     <h:form>
     <table border="0" cellpadding="3" cellspacing="1" width="100%" class="forumline">
     	<!-- title -->
@@ -245,6 +246,29 @@
     </table>
     </h:form>
     </c:if>
+    
+    <!-- in case of anonymous access -->
+    <c:if test="#{prefController.anonymous==true}">
+    	<table class="forumline" width="100%" cellspacing="1" cellpadding="4" border="0">
+		   <tr>
+		      <td>
+		         <table width="100%" cellspacing="0" cellpadding="1" border="0">
+		            <tr>
+		               <td>&amp;nbsp;</td>
+		            </tr>
+		            <tr>
+		               <td align="center">
+		                	<h:outputText value="You must be logged in to manage your Forum Preferences" styleClass="gen"/>               	
+		               </td>
+		            </tr>
+		            <tr>
+		               <td>&amp;nbsp;</td>
+		            </tr>		            
+		         </table>
+		      </td>
+		   </tr>
+		</table>
+    </c:if>
    
    </ui:define>
    </ui:composition>   




More information about the jboss-svn-commits mailing list