rave-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlu...@apache.org
Subject svn commit: r1172793 - in /incubator/rave/trunk: rave-demo-gadgets/src/main/webapp/user_prefs_demo.xml rave-portal/src/main/resources/initial_data.sql
Date Mon, 19 Sep 2011 20:15:59 GMT
Author: carlucci
Date: Mon Sep 19 20:15:59 2011
New Revision: 1172793

URL: http://svn.apache.org/viewvc?rev=1172793&view=rev
Log:
RAVE-250: added "User Prefs Demo" gadget to rave-demo-gadgets as an example for the capabilities
of OpenSocial user prefs and how our container handles them

Added:
    incubator/rave/trunk/rave-demo-gadgets/src/main/webapp/user_prefs_demo.xml
Modified:
    incubator/rave/trunk/rave-portal/src/main/resources/initial_data.sql

Added: incubator/rave/trunk/rave-demo-gadgets/src/main/webapp/user_prefs_demo.xml
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-demo-gadgets/src/main/webapp/user_prefs_demo.xml?rev=1172793&view=auto
==============================================================================
--- incubator/rave/trunk/rave-demo-gadgets/src/main/webapp/user_prefs_demo.xml (added)
+++ incubator/rave/trunk/rave-demo-gadgets/src/main/webapp/user_prefs_demo.xml Mon Sep 19
20:15:59 2011
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  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.
+-->
+<Module>
+    <ModulePrefs title="User Prefs Demo"
+                 description="An example gadget which demos some of the different capabilities
of user preferences."
+                 author="Anthony Carlucci"
+                 author_email="acarlucci@mitre.org">
+        <Require feature="dynamic-height" />
+        <Require feature="setprefs" />
+    </ModulePrefs>
+    <UserPref name="age"
+              display_name="Age" 
+              default_value="0" 
+              datatype="string"/>
+    <UserPref name="full_name"
+              display_name="Full Name" 
+              required="true"
+              datatype="string"/>
+    <UserPref name="bool_test"
+              display_name="Boolean Type" 
+              datatype="bool"/>
+    <UserPref name="hidden_test"
+              display_name="Hidden Value"
+              default_value="secret value"
+              datatype="hidden"/>  
+    <UserPref name="color" 
+              display_name="Color (Enum)" 
+              default_value="yellow"
+              datatype="enum"> 
+        <EnumValue value="red" display_value="Red (first)" />
+        <EnumValue value="aqua" display_value="Aqua (second)" />
+        <EnumValue value="lime" display_value="Lime (third)" />
+        <EnumValue value="yellow" display_value="Yellow (fourth)" />
+        <EnumValue value="pink" display_value="Pink (fifth)" />
+        <EnumValue value="orange" display_value="Orange (sixth)" />
+        <EnumValue value="white" display_value="White (seventh)" />
+    </UserPref> 
+    <UserPref name="drinks"
+              display_name="Drinks (List Type With Defaults)"
+              datatype="list"
+              required="false"
+              default_value="coke|pepsi|fruit punch"/>
+    <UserPref name="movies"
+              display_name="Movies (Required List Type With Defaults)"
+              datatype="list"
+              required="true"
+              default_value="Terminator|Forrest Gump|Predator"/>
+    <UserPref name="openlist"
+              display_name="List Type No Defaults"
+              datatype="list"
+              required="false" />
+    <Content type="html">
+        <![CDATA[
+            <div style="padding-bottom: 10px;">Below is a list of User Prefs for this
gadget.  Click the Edit Prefs icon in the gadget titlebar to change the values.</div>
+            <div id="content_div"></div>
+            <div>
+                <div>Click the button below to demo saving user prefs inline.  It will
save the "Age" to 999 and the "Drinks" to "lemonade,tea".</div>
+                <button onClick="saveInlinePref();">Save Inline</button>
+            </div>
+
+            <script type="text/javascript">
+                function saveInlinePref() {
+                    var prefs = new gadgets.Prefs();
+                    prefs.set("age", "999");
+                    prefs.setArray("drinks",["lemonade","tea"]);
+                    renderContent();
+                }
+
+                function renderContent() {
+                    var prefs = new gadgets.Prefs();
+                    var age = prefs.getString("age");
+                    var fullName = prefs.getString("full_name");
+                    var boolType = prefs.getBool("bool_test");
+                    var hiddenType = prefs.getString("hidden_test");
+                    var enumType = prefs.getString("color");
+                    var drinksArray = prefs.getArray("drinks");
+                    var moviesArray = prefs.getArray("movies");
+                    var openListArray = prefs.getArray("openlist");
+
+                    var drinksHtml = "<ul>";
+                    for (var i=0; i < drinksArray.length; i++) {
+                        drinksHtml += "<li>" + drinksArray[i];
+                    }
+                    drinksHtml += "</ul>";
+
+                    var moviesHtml = "<ul>";
+                    for (var i=0; i < moviesArray.length; i++) {
+                        moviesHtml += "<li>" + moviesArray[i];
+                    }
+                    moviesHtml += "</ul>";
+
+                    var openListHtml = "<ul>";
+                    for (var i=0; i < openListArray.length; i++) {
+                        openListHtml += "<li>" + openListArray[i];
+                    }
+                    openListHtml += "</ul>";
+
+                    var gadgetHtml = "<ul>" +
+                                    "<li>Your age is: " + age +
+                                    "<li>Your name is: " + fullName +
+                                    "<li>Bool Type: " + boolType +
+                                    "<li>Hidden Type: " + hiddenType +
+                                    "<li>Color (enum): " + enumType +
+                                    "<li>Drinks (List w/defaults): " + drinksHtml +
+                                    "<li>Movies (List w/defaults and required): " +
moviesHtml +
+                                    "<li>Open List (List w/o defaults): " + openListHtml
+
+                                    "</ul>";
+
+                    document.getElementById('content_div').innerHTML = gadgetHtml;
+                    gadgets.window.adjustHeight();                
+                }
+
+                gadgets.util.registerOnLoadHandler(function() {
+                    renderContent();
+                });
+                
+            </script>    
+        ]]> 
+    </Content>
+</Module>
\ No newline at end of file

Modified: incubator/rave/trunk/rave-portal/src/main/resources/initial_data.sql
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-portal/src/main/resources/initial_data.sql?rev=1172793&r1=1172792&r2=1172793&view=diff
==============================================================================
--- incubator/rave/trunk/rave-portal/src/main/resources/initial_data.sql (original)
+++ incubator/rave/trunk/rave-portal/src/main/resources/initial_data.sql Mon Sep 19 20:15:59
2011
@@ -216,6 +216,12 @@ insert into widget (entity_id, title, ur
 values(@gadgetview_widget_id, 'Gadget View Type', 'http://localhost:8080/demogadgets/canvas-nav.xml',
'OpenSocial', 'PUBLISHED');
 UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @widget_seq;
 
+-- View information
+set @user_prefs_demo_widget_id = (SELECT seq_count FROM RAVE_PORTAL_SEQUENCES WHERE seq_name
= @widget_seq);
+insert into widget (entity_id, title, url, type, widget_status, description, author)
+values(@user_prefs_demo_widget_id, 'User Prefs Demo', 'http://localhost:8080/demogadgets/user_prefs_demo.xml',
'OpenSocial', 'PUBLISHED', 'An example gadget which demos some of the different capabilities
of user preferences.', 'Anthony Carlucci');
+UPDATE RAVE_PORTAL_SEQUENCES SET seq_count = (seq_count + 1) WHERE seq_name = @widget_seq;
+
 -- end widget data ----
 
 -- User layouts



Mime
View raw message