Author: scottbw
Date: Fri Aug  3 09:46:41 2012
New Revision: 1368850

URL: http://svn.apache.org/viewvc?rev=1368850&view=rev
Log:
Created a REST API method for returning a rendered RegionWidget, for use in 
populating a page without refreshing it (see RAVE-743)

Added:
    
rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/RegionWidgetController.java
    
rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/templates/partial_layout.jsp
    
rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/regionwidget.jsp
Modified:
    
rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
    
rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ViewNames.java
    rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/tiles-defs.xml

Added: 
rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/RegionWidgetController.java
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/RegionWidgetController.java?rev=1368850&view=auto
==============================================================================
--- 
rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/RegionWidgetController.java
 (added)
+++ 
rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/controller/RegionWidgetController.java
 Fri Aug  3 09:46:41 2012
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.rave.portal.web.controller;
+
+import org.apache.rave.portal.model.RegionWidget;
+import org.apache.rave.portal.service.RegionWidgetService;
+import org.apache.rave.portal.web.util.ModelKeys;
+import org.apache.rave.portal.web.util.ViewNames;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+@Controller
+public class RegionWidgetController {
+       
+       private RegionWidgetService regionWidgetService;
+       
+       @Autowired
+       public RegionWidgetController(RegionWidgetService regionWidgetService){
+               this.regionWidgetService = regionWidgetService;
+       }
+
+    @RequestMapping(value = {"/api/rest/regionwidget/{regionWidgetId}"}, 
method = RequestMethod.GET)
+    public String  viewRegionWidget(Model model, @PathVariable Long 
regionWidgetId){
+       RegionWidget rw = regionWidgetService.getRegionWidget(regionWidgetId);
+        model.addAttribute(ModelKeys.REGION_WIDGET, rw);
+       return ViewNames.REGION_WIDGET;
+    }
+    
+}

Modified: 
rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java?rev=1368850&r1=1368849&r2=1368850&view=diff
==============================================================================
--- 
rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
 (original)
+++ 
rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ModelKeys.java
 Fri Aug  3 09:46:41 2012
@@ -33,6 +33,7 @@ public class ModelKeys {
     public static final String ERROR_MESSAGE = "errorMessage"; // an error 
message to be reported to the user
     public static final String WIDGETS = "widgets"; // a list of widget objects
     public static final String WIDGET = "widget";
+    public static final String REGION_WIDGET = "regionWidget";    
     public static final String WIDGET_STATISTICS = "widgetStatistics"; 
//statistics for a single widget
     public static final String WIDGETS_STATISTICS = "widgetsStatistics"; 
//list of statistics for a list of widgets
     public static final String CATEGORY = "category"; //category

Modified: 
rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ViewNames.java
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ViewNames.java?rev=1368850&r1=1368849&r2=1368850&view=diff
==============================================================================
--- 
rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ViewNames.java
 (original)
+++ 
rave/trunk/rave-components/rave-web/src/main/java/org/apache/rave/portal/web/util/ViewNames.java
 Fri Aug  3 09:46:41 2012
@@ -26,11 +26,13 @@ public final class ViewNames {
     private ViewNames() {}
     private static final String USER_PREFIX = "templates.user.";
     private static final String ADMIN_PREFIX = "templates.admin.";
-
+    private static final String PARTIAL_PREFIX = "templates.partial.";
+    
     public static final String PAGE = USER_PREFIX + "page";
     public static final String MOBILE_HOME = USER_PREFIX + "mobile_home";
     public static final String STORE = USER_PREFIX + "store";
     public static final String WIDGET = USER_PREFIX + "widget";
+    public static final String REGION_WIDGET = PARTIAL_PREFIX + "regionwidget";
     public static final String ADD_WIDGET_FORM = USER_PREFIX + "addwidget";
     public static final String NEW_ACCOUNT = USER_PREFIX + "newaccount";
     public static final String USER_PROFILE = USER_PREFIX + "userProfile";

Added: 
rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/templates/partial_layout.jsp
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/templates/partial_layout.jsp?rev=1368850&view=auto
==============================================================================
--- 
rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/templates/partial_layout.jsp
 (added)
+++ 
rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/templates/partial_layout.jsp
 Fri Aug  3 09:46:41 2012
@@ -0,0 +1,27 @@
+<%--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+--%>
+<%@ page language="java" trimDirectiveWhitespaces="true" %>
+<%@ page errorPage="/WEB-INF/jsp/views/error.jsp" %>
+<%@ include file="/WEB-INF/jsp/includes/taglibs.jsp" %>
+<%-- Expose any attributes defined in the tiles-defs.xml to the request scope 
for use in other tiles --%>
+<tiles:importAttribute scope="request"/>
+
+<!-- Begin Partial -->
+<tiles:insertAttribute name="body"/>
+<!-- End Partial -->
\ No newline at end of file

Added: 
rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/regionwidget.jsp
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/regionwidget.jsp?rev=1368850&view=auto
==============================================================================
--- 
rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/regionwidget.jsp
 (added)
+++ 
rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/jsp/views/regionwidget.jsp
 Fri Aug  3 09:46:41 2012
@@ -0,0 +1,25 @@
+<%@ taglib prefix="portal" uri="http://www.apache.org/rave/tags"; %>
+<%--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  --%>
+<%@ page language="java" trimDirectiveWhitespaces="true" %>
+<%@ include file="/WEB-INF/jsp/includes/taglibs.jsp" %>
+<fmt:setBundle basename="messages"/>
+<%--@elvariable id="regionWidget" 
type="org.apache.rave.portal.model.RegionWidget"--%>
+<rave:region_widget regionWidget="${regionWidget}"/>
+<portal:render-script location="${'AFTER_RAVE'}" />
\ No newline at end of file

Modified: 
rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/tiles-defs.xml
URL: 
http://svn.apache.org/viewvc/rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/tiles-defs.xml?rev=1368850&r1=1368849&r2=1368850&view=diff
==============================================================================
--- rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/tiles-defs.xml 
(original)
+++ rave/trunk/rave-portal-resources/src/main/webapp/WEB-INF/tiles-defs.xml Fri 
Aug  3 09:46:41 2012
@@ -22,6 +22,14 @@
 
 <tiles-definitions>
 
+       <!-- PARTIALS -->
+       <definition name="templates.partial" 
template="/WEB-INF/jsp/templates/partial_layout.jsp">
+    </definition>
+    
+    <definition name="templates.partial.regionwidget" 
extends="templates.partial">
+        <put-attribute name="body" 
value="/WEB-INF/jsp/views/regionwidget.jsp"/>
+    </definition>
+
     <!-- BASE DEFINITIONS FOR THE ENTIRE APPLICATION -->
     <definition name="templates.base" 
template="/WEB-INF/jsp/templates/base_layout.jsp">
         <put-attribute name="pageTitleKey" value="page.general.title"/>


Reply via email to