portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r908570 - in /portals/jetspeed-2/applications/j2-admin/trunk/src/main: java/org/apache/jetspeed/portlets/toolbox/JetspeedToolbox.java webapp/WEB-INF/portlet.xml webapp/WEB-INF/view/toolbox/toolbox.jsp
Date Wed, 10 Feb 2010 16:28:55 GMT
Author: woonsan
Date: Wed Feb 10 16:28:54 2010
New Revision: 908570

URL: http://svn.apache.org/viewvc?rev=908570&view=rev
Log:
JS2-1057: Adding preference for default category selection.

Modified:
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/toolbox/JetspeedToolbox.java
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml
    portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/toolbox/JetspeedToolbox.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/toolbox/JetspeedToolbox.java?rev=908570&r1=908569&r2=908570&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/toolbox/JetspeedToolbox.java
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/toolbox/JetspeedToolbox.java
Wed Feb 10 16:28:54 2010
@@ -105,6 +105,7 @@
     public void doView(RenderRequest request, RenderResponse response)
             throws PortletException, IOException
     {
+        request.setAttribute("defaultCategory", getDefaultCategory(request, ""));
         List<String> categories = retrieveCategories(request);
         request.setAttribute("categories", categories);
         Map<String, String> categoryKeywordsMap = retrieveCategoryKeywordsMap(categories,
request);
@@ -169,10 +170,15 @@
                 log.error("Page has not been updated.", e);
             }            
         }
-    }    
+    }
+    
+    protected String getDefaultCategory(PortletRequest request, String defaultValue) throws
PortletException
+    {
+        return request.getPreferences().getValue("DefaultCategory", defaultValue);
+    }
     
     @SuppressWarnings("unchecked")
-    public List<String> retrieveCategories(PortletRequest request) throws PortletException
+    protected List<String> retrieveCategories(PortletRequest request) throws PortletException
     {
         List<String> categories = (List) request.getPortletSession().getAttribute("categories");
         
@@ -195,7 +201,7 @@
         return categories;
     }
     
-    public Map<String, String> retrieveCategoryKeywordsMap(List<String> categories,
PortletRequest request) throws PortletException
+    protected Map<String, String> retrieveCategoryKeywordsMap(List<String> categories,
PortletRequest request) throws PortletException
     {
         Map<String, String> keywordsMap = new HashMap<String, String>();
         PortletPreferences prefs = request.getPreferences();

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml?rev=908570&r1=908569&r2=908570&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml (original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/portlet.xml Wed
Feb 10 16:28:54 2010
@@ -2256,6 +2256,10 @@
     </portlet-info>
     <portlet-preferences>
       <preference>
+        <name>DefaultCategory</name>
+        <value>News</value>
+      </preference>
+      <preference>
         <name>Categories</name>
         <value>Administration,Finance,Fun,News,Security,Sports,Technology,Tools,Tutorial</value>
       </preference>

Modified: portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp?rev=908570&r1=908569&r2=908570&view=diff
==============================================================================
--- portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
(original)
+++ portals/jetspeed-2/applications/j2-admin/trunk/src/main/webapp/WEB-INF/view/toolbox/toolbox.jsp
Wed Feb 10 16:28:54 2010
@@ -355,16 +355,18 @@
         if (tabId == "portlets") {
 	        var category = Y.Cookie.get("toolboxcat");
 	        if (!category) {
-		        category = "News";
+		        category = "${defaultCategory}";
+	        }
+	        if (category) {
+	            var categories = Y.Node.getDOMNode(Y.Node.one("#<portlet:namespace/>categories"));
+	            for (var i = 0; i < categories.options.length; i++) {
+	                if (category == categories.options[i].value && i != categories.selectedIndex)
{
+	                    categories.options[i].selected = true;
+	                    loadPortletsInCategory(category);
+	                    break;
+	                }
+	            }
 	        }
-            var categories = Y.Node.getDOMNode(Y.Node.one("#<portlet:namespace/>categories"));
-            for (var i = 0; i < categories.options.length; i++) {
-                if (category == categories.options[i].value && i != categories.selectedIndex)
{
-                    categories.options[i].selected = true;
-                    loadPortletsInCategory(category);
-                    break;
-                }
-            }
         }
 
         if ('string' != typeof(e)) {



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message