portals-portalapps-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From woon...@apache.org
Subject svn commit: r945785 - in /portals/applications/sandbox/content/trunk/src/main: java/org/apache/portals/applications/content/ webapp/WEB-INF/view/
Date Tue, 18 May 2010 17:46:03 GMT
Author: woonsan
Date: Tue May 18 17:46:02 2010
New Revision: 945785

URL: http://svn.apache.org/viewvc?rev=945785&view=rev
Log:
Adding preferences edit pages

Modified:
    portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java
    portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java
    portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-content-edit.jsp
    portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-query-content-edit.jsp
    portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-edit.jsp
    portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/simple-search-query-content-edit.jsp

Modified: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java?rev=945785&r1=945784&r2=945785&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java
(original)
+++ portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericContentPortlet.java
Tue May 18 17:46:02 2010
@@ -17,6 +17,7 @@
 package org.apache.portals.applications.content;
 
 import java.io.IOException;
+import java.util.Map;
 
 import javax.jcr.Credentials;
 import javax.jcr.Repository;
@@ -24,8 +25,12 @@ import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
 import javax.portlet.PortletConfig;
 import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletPreferences;
 import javax.portlet.PortletRequest;
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
@@ -52,6 +57,8 @@ public class GenericContentPortlet exten
     
     private String contentBeanAttributeName = "contentBean";
     
+    private String preferenceRequestParamPrefix = "preference.";
+    
     @Override
     public void init(PortletConfig config) throws PortletException 
     {
@@ -98,6 +105,13 @@ public class GenericContentPortlet exten
         {
             contentBeanAttributeName = param;
         }
+        
+        param = StringUtils.trim(getInitParameterFromConfigOrContext(config, "contentBeanAttributeName",
null));
+        
+        if (param != null)
+        {
+            preferenceRequestParamPrefix = param;
+        }
     }
     
     @Override
@@ -151,6 +165,19 @@ public class GenericContentPortlet exten
         }
     }
     
+    @Override
+    public void processAction(ActionRequest request, ActionResponse response) throws PortletException,
IOException
+    {
+        if (isPreferencesStoringAction(request))
+        {
+            processPreferencesAction(request, response);
+        }
+        else
+        {
+            super.processAction(request, response);
+        }
+    }
+    
     protected Object getContentBean(final PortletRequest request, final ObjectContentManager
ocm, final String contentPath) throws PortletException
     {
         Object contentBean = ocm.getObject(contentPath);
@@ -247,4 +274,60 @@ public class GenericContentPortlet exten
         
         return (value != null ? value.trim() : defaultValue);
     }
+    
+    protected boolean isPreferencesStoringAction(ActionRequest request)
+    {
+        String preferenceActionParamName = StringUtils.join(new Object [] { preferenceRequestParamPrefix,
"action" });
+        return ("store".equals(request.getParameter(preferenceActionParamName)));
+    }
+    
+    @Override
+    public void processPreferencesAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException
+    {
+        Map<String, String []> params = request.getParameterMap();
+        PortletPreferences prefs = request.getPreferences();
+        Map<String, String []> prefsMap = prefs.getMap();
+
+        try
+        {
+            boolean preferenceRequestParamsPrefixed = !StringUtils.isEmpty(preferenceRequestParamPrefix);
+            
+            for (Map.Entry<String, String []> entry : params.entrySet())
+            {
+                String paramName = entry.getKey();
+                String [] values = entry.getValue();
+                String prefName = null;
+                
+                if (!preferenceRequestParamsPrefixed)
+                {
+                    prefName = paramName;
+                }
+                else
+                {
+                    if (!paramName.startsWith(preferenceRequestParamPrefix))
+                    {
+                        continue;
+                    }
+                    
+                    prefName = paramName.substring(preferenceRequestParamPrefix.length());
+                }
+                
+                if (!prefsMap.containsKey(prefName))
+                {
+                    continue;
+                }
+                
+                prefs.setValue(prefName, values[0]);
+            }
+            
+            prefs.store();
+            
+            response.setPortletMode(PortletMode.VIEW);
+        }
+        catch (Exception e)
+        {
+            throw new PortletException("Exception mapping request Params to Preferences:
", e);
+        }
+    }
+    
 }

Modified: portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java?rev=945785&r1=945784&r2=945785&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java
(original)
+++ portals/applications/sandbox/content/trunk/src/main/java/org/apache/portals/applications/content/GenericSearchQueryContentPortlet.java
Tue May 18 17:46:02 2010
@@ -37,6 +37,12 @@ public class GenericSearchQueryContentPo
     @Override
     public void processAction(ActionRequest request, ActionResponse response) throws PortletException,
IOException
     {
+        if (isPreferencesStoringAction(request))
+        {
+            processPreferencesAction(request, response);
+            return;
+        }
+        
         String query = request.getParameter("query");
         String queryNode = request.getParameter("queryNode");
         String queryOperator = request.getParameter("queryOperator");

Modified: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-content-edit.jsp
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-content-edit.jsp?rev=945785&r1=945784&r2=945785&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-content-edit.jsp
(original)
+++ portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-content-edit.jsp
Tue May 18 17:46:02 2010
@@ -21,5 +21,18 @@ limitations under the License.
 <portlet:defineObjects/>
 <fmt-portlet:setBundle/>
 
-<h1>Content edit page</h1>
-<hr/>
+<form method="POST" action="<portlet:actionURL/>">
+  <table>
+    <tr>
+      <td class="portlet-section-body">Content Path:</td>
+      <td class="portlet-section-body"><input type="text" name="preference.contentPath"
size="40" value="${renderRequest.preferences.map['contentPath'][0]}" />
+    </tr>
+    <tr>
+      <td colspan="2" class="portlet-section-body">
+        <input type="hidden" name="preference.action" value="store" />
+        <input type="submit" value="Save" />
+        <input type="reset" value="Reset" />
+      </td>
+    </tr>
+  </table>
+</form>

Modified: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-query-content-edit.jsp
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-query-content-edit.jsp?rev=945785&r1=945784&r2=945785&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-query-content-edit.jsp
(original)
+++ portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-query-content-edit.jsp
Tue May 18 17:46:02 2010
@@ -21,5 +21,34 @@ limitations under the License.
 <portlet:defineObjects/>
 <fmt-portlet:setBundle/>
 
-<h1>Content query result edit page</h1>
-<hr/>
+<form method="POST" action="<portlet:actionURL/>">
+  <table>
+    <tr>
+      <td class="portlet-section-body">Content Base Path:</td>
+      <td class="portlet-section-body"><input type="text" name="preference.contentPath"
size="40" value="${renderRequest.preferences.map['contentPath'][0]}" />
+    </tr>
+    <tr>
+      <td class="portlet-section-body">Content URL Base:</td>
+      <td class="portlet-section-body"><input type="text" name="preference.contentUrlBase"
size="40" value="${renderRequest.preferences.map['contentUrlBase'][0]}" />
+    </tr>
+    <tr>
+      <td class="portlet-section-body">Query Class:</td>
+      <td class="portlet-section-body"><input type="text" name="preference.queryClass"
size="40" value="${renderRequest.preferences.map['queryClass'][0]}" />
+    </tr>
+    <tr>
+      <td class="portlet-section-body">Page Size:</td>
+      <td class="portlet-section-body"><input type="text" name="preference.pageSize"
size="40" value="${renderRequest.preferences.map['pageSize'][0]}" />
+    </tr>
+    <tr>
+      <td class="portlet-section-body">Order-by clause:</td>
+      <td class="portlet-section-body"><input type="text" name="preference.queryOrderByClause"
size="40" value="${renderRequest.preferences.map['queryOrderByClause'][0]}" />
+    </tr>
+    <tr>
+      <td colspan="2" class="portlet-section-body">
+        <input type="hidden" name="preference.action" value="store" />
+        <input type="submit" value="Save" />
+        <input type="reset" value="Reset" />
+      </td>
+    </tr>
+  </table>
+</form>

Modified: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-edit.jsp
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-edit.jsp?rev=945785&r1=945784&r2=945785&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-edit.jsp
(original)
+++ portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/generic-search-query-content-edit.jsp
Tue May 18 17:46:02 2010
@@ -21,5 +21,34 @@ limitations under the License.
 <portlet:defineObjects/>
 <fmt-portlet:setBundle/>
 
-<h1>Content search query result edit page</h1>
-<hr/>
+<form method="POST" action="<portlet:actionURL/>">
+  <table>
+    <tr>
+      <td class="portlet-section-body">Content Base Path:</td>
+      <td class="portlet-section-body"><input type="text" name="preference.contentPath"
size="40" value="${renderRequest.preferences.map['contentPath'][0]}" />
+    </tr>
+    <tr>
+      <td class="portlet-section-body">Content URL Base:</td>
+      <td class="portlet-section-body"><input type="text" name="preference.contentUrlBase"
size="40" value="${renderRequest.preferences.map['contentUrlBase'][0]}" />
+    </tr>
+    <tr>
+      <td class="portlet-section-body">Query Class:</td>
+      <td class="portlet-section-body"><input type="text" name="preference.queryClass"
size="40" value="${renderRequest.preferences.map['queryClass'][0]}" />
+    </tr>
+    <tr>
+      <td class="portlet-section-body">Page Size:</td>
+      <td class="portlet-section-body"><input type="text" name="preference.pageSize"
size="40" value="${renderRequest.preferences.map['pageSize'][0]}" />
+    </tr>
+    <tr>
+      <td class="portlet-section-body">Order-by clause:</td>
+      <td class="portlet-section-body"><input type="text" name="preference.queryOrderByClause"
size="40" value="${renderRequest.preferences.map['queryOrderByClause'][0]}" />
+    </tr>
+    <tr>
+      <td colspan="2" class="portlet-section-body">
+        <input type="hidden" name="preference.action" value="store" />
+        <input type="submit" value="Save" />
+        <input type="reset" value="Reset" />
+      </td>
+    </tr>
+  </table>
+</form>

Modified: portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/simple-search-query-content-edit.jsp
URL: http://svn.apache.org/viewvc/portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/simple-search-query-content-edit.jsp?rev=945785&r1=945784&r2=945785&view=diff
==============================================================================
--- portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/simple-search-query-content-edit.jsp
(original)
+++ portals/applications/sandbox/content/trunk/src/main/webapp/WEB-INF/view/simple-search-query-content-edit.jsp
Tue May 18 17:46:02 2010
@@ -21,5 +21,34 @@ limitations under the License.
 <portlet:defineObjects/>
 <fmt-portlet:setBundle/>
 
-<h1>Simple search query result edit page</h1>
-<hr/>
+<form method="POST" action="<portlet:actionURL/>">
+  <table>
+    <tr>
+      <td class="portlet-section-body">Content URL Base:</td>
+      <td class="portlet-section-body"><input type="text" name="preference.contentUrlBase"
size="40" value="${renderRequest.preferences.map['contentUrlBase'][0]}" />
+    </tr>
+    <tr>
+      <td class="portlet-section-body">Query Class:</td>
+      <td class="portlet-section-body"><input type="text" name="preference.queryClass"
size="40" value="${renderRequest.preferences.map['queryClass'][0]}" />
+    </tr>
+    <tr>
+      <td class="portlet-section-body">Query Language:</td>
+      <td class="portlet-section-body"><input type="text" name="preference.queryLanguage"
size="40" value="${renderRequest.preferences.map['queryLanguage'][0]}" />
+    </tr>
+    <tr>
+      <td class="portlet-section-body">Page Size:</td>
+      <td class="portlet-section-body"><input type="text" name="preference.pageSize"
size="40" value="${renderRequest.preferences.map['pageSize'][0]}" />
+    </tr>
+    <tr>
+      <td class="portlet-section-body">Order-by clause:</td>
+      <td class="portlet-section-body"><input type="text" name="preference.queryOrderByClause"
size="40" value="${renderRequest.preferences.map['queryOrderByClause'][0]}" />
+    </tr>
+    <tr>
+      <td colspan="2" class="portlet-section-body">
+        <input type="hidden" name="preference.action" value="store" />
+        <input type="submit" value="Save" />
+        <input type="reset" value="Reset" />
+      </td>
+    </tr>
+  </table>
+</form>



Mime
View raw message