You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2008/03/14 12:22:46 UTC
svn commit: r637063 - in /incubator/sling/trunk/extensions/dojo-ujax: ./
src/ src/main/ src/main/resources/ src/main/resources/META-INF/
src/main/resources/SLING-INF/ src/main/resources/SLING-INF/content/
src/main/resources/SLING-INF/content/dojox/ src...
Author: fmeschbe
Date: Fri Mar 14 04:22:43 2008
New Revision: 637063
URL: http://svn.apache.org/viewvc?rev=637063&view=rev
Log:
SLING-301 Dojo Classes for accessing the repository via the µjax protocol
Added:
incubator/sling/trunk/extensions/dojo-ujax/ (with props)
incubator/sling/trunk/extensions/dojo-ujax/pom.xml (with props)
incubator/sling/trunk/extensions/dojo-ujax/src/
incubator/sling/trunk/extensions/dojo-ujax/src/main/
incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/
incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/META-INF/
incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/META-INF/LICENSE
incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/META-INF/NOTICE
incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/
incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/
incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/
incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/
incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/
incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/README-JCR.txt (with props)
incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo1.html (with props)
incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo2.html (with props)
incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo3.html (with props)
incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/dojox/
incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/dojox/data/
incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/dojox/data/SlingNodeStore.js (with props)
incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/dojox/data/SlingPropertyStore.js (with props)
Propchange: incubator/sling/trunk/extensions/dojo-ujax/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Mar 14 04:22:43 2008
@@ -0,0 +1,4 @@
+.classpath
+.settings
+.project
+target
Added: incubator/sling/trunk/extensions/dojo-ujax/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/dojo-ujax/pom.xml?rev=637063&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/dojo-ujax/pom.xml (added)
+++ incubator/sling/trunk/extensions/dojo-ujax/pom.xml Fri Mar 14 04:22:43 2008
@@ -0,0 +1,79 @@
+<?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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>1-incubator-SNAPSHOT</version>
+ <relativePath>../../parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>org.apache.sling.extensions.dojo.ujax</artifactId>
+ <version>2.0.0-incubator-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>Sling Dojo Data Exension for ujax</name>
+ <description>
+ This bundle provides support to look at the repository using
+ Dojo.
+ </description>
+
+ <scm>
+ <connection>
+ scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/extensions/dojo-ujax
+ </connection>
+ <developerConnection>
+ scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/extensions/dojo-ujax
+ </developerConnection>
+ <url>
+ http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/dojo-ujax
+ </url>
+ </scm>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ <!-- Nothing to Export -->
+ </Export-Package>
+
+ <!-- The demos are loaded into the repository -->
+ <Sling-Initial-Content>
+ SLING-INF/content
+ </Sling-Initial-Content>
+
+ <!-- The scripts are provided as Bundle Resources -->
+ <Sling-Bundle-Resources>
+ /dojox/data
+ </Sling-Bundle-Resources>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Propchange: incubator/sling/trunk/extensions/dojo-ujax/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/META-INF/LICENSE
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/META-INF/LICENSE?rev=637063&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/META-INF/LICENSE (added)
+++ incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/META-INF/LICENSE Fri Mar 14 04:22:43 2008
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
Added: incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/META-INF/NOTICE
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/META-INF/NOTICE?rev=637063&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/META-INF/NOTICE (added)
+++ incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/META-INF/NOTICE Fri Mar 14 04:22:43 2008
@@ -0,0 +1,8 @@
+Apache Sling Dojo JavaScript Library
+Copyright 2007 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+This product includes software developed at
+The Dojo Foundation (http://www.dojotoolkit.org/).
Added: incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/README-JCR.txt
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/README-JCR.txt?rev=637063&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/README-JCR.txt (added)
+++ incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/README-JCR.txt Fri Mar 14 04:22:43 2008
@@ -0,0 +1,2 @@
+This folder contains demo pages showing how to use the Dojo Classes
+dojox.data.SlingNodeStore and dojox.data.SlingPropertyStore.
\ No newline at end of file
Propchange: incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/README-JCR.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo1.html
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo1.html?rev=637063&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo1.html (added)
+++ incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo1.html Fri Mar 14 04:22:43 2008
@@ -0,0 +1,96 @@
+<!--
+ This file is a demo of multiple dojo.data aware widgets using different datastore implementations for displaying data.
+-->
+<html>
+<head>
+ <title>Demo of Multiple Widgets using the µjax Data Store</title>
+ <style type="text/css">
+ @import "../../../dijit/themes/tundra/tundra.css";
+ @import "../../../dojo/resources/dojo.css";
+ @import "../../../dijit/tests/css/dijitTests.css";
+ @import "../../../dojox/grid/_grid/tundraGrid.css";
+ </style>
+
+ <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true, usePlainJson: true"></script>
+ <script type="text/javascript">
+ dojo.require("dojo.parser");
+ dojo.require("dijit.form.ComboBox");
+ dojo.require("dijit.Tree");
+ dojo.require("dojox.data.SlingNodeStore");
+ dojo.require("dojox.data.SlingPropertyStore");
+ dojo.require("dojox.grid._data.model");
+ dojo.require("dojox.grid.Grid");
+ dojo.require("dojox.grid._data.editors");
+ </script>
+</head>
+
+<body class="tundra">
+ <h1>
+ DEMO: µjax Data Store
+ </h1>
+
+ <!-- the data store -->
+ <div dojoType="dojox.data.SlingPropertyStore" url="/dojo" jsId="propertyStore">
+ <script type="dojo/connect" event="onSet" args="item,attr,oldVal,newVal">
+ console.debug("About to change "+attr+" from "+oldVal+" to "+newVal);
+ // Save the record with dojo.xhrPost or your favorite remote method
+ </script>
+ </div>
+ <div dojoType="dojox.data.SlingNodeStore" url="/" jsId="nodeStore"></div>
+
+
+
+ <h3>
+ Widgets using µjaxStore:
+ </h3>
+ <blockquote>
+ <table width="100%">
+ <tbody>
+ <tr>
+ <td>
+
+ <b>Tree (only root and folders):</b><br>
+ <div dojoType="dijit.Tree" id="tree1" store="nodeStore" query="{ query: { 'jcr:primaryType' : ['nt:folder', 'rep:root'] } }"></div>
+
+ </td>
+ <td>
+
+ <b>Tree (only root and folders and files):</b><br>
+ <div dojoType="dijit.Tree" id="tree2" store="nodeStore" query="{ query: { 'jcr:primaryType' : ['nt:folder', 'rep:root', 'nt:file'] } }"></div>
+
+ </td>
+ <td>
+
+ <b>Tree (complete):</b><br>
+ <div dojoType="dijit.Tree" id="tree3" store="nodeStore"></div>
+
+
+ </td>
+ </tr>
+ </tbody>
+ </table>
+
+
+
+ <!-- the data model (for the grid) -->
+ <div dojoType="dojox.grid.data.DojoData" jsId="propertyModel"
+ store="propertyStore" clientSort="true">
+ </div>
+
+ <script type="text/javascript">
+ var tableview = {
+ cells: [
+ [
+ {name: "URI", field:"uri"},
+ {name: "Name", field: "name", width:"200px" },
+ {name: "Value", field: "value", width:"200px", editor:dojox.grid.editors.TextBox, field:2 }
+ ]
+ ]
+ };
+
+ var tablestructure = [ tableview ];
+ </script>
+
+ <div id="grid" dojoType="dojox.Grid" model="propertyModel" structure="tablestructure"></div>
+</body>
+</html>
Propchange: incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo1.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo2.html
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo2.html?rev=637063&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo2.html (added)
+++ incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo2.html Fri Mar 14 04:22:43 2008
@@ -0,0 +1,146 @@
+<!--
+ This file is a demo of multiple dojo.data aware widgets using different datastore implementations for displaying data.
+-->
+<html>
+<head>
+ <title>Demo of Multiple Widgets using the µjax Data Store</title>
+ <style type="text/css">
+ @import "../../../dijit/themes/tundra/tundra.css";
+ @import "../../../dojo/resources/dojo.css";
+ @import "../../../dijit/tests/css/dijitTests.css";
+ @import "../../../dojox/grid/_grid/tundraGrid.css";
+ </style>
+
+ <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true, debugAtAllCosts: true, usePlainJson: true"></script>
+ <script type="text/javascript">
+ dojo.require("dojo.parser");
+ dojo.require("dijit.form.ComboBox");
+ dojo.require("dijit.Tree");
+ dojo.require("dojox.data.SlingNodeStore");
+ dojo.require("dojox.data.SlingPropertyStore");
+ dojo.require("dojox.grid._data.model");
+ dojo.require("dojox.grid.Grid");
+ dojo.require("dojox.grid._data.editors");
+ dojo.require("dijit.form.Form");
+ dojo.require("dijit.layout.LayoutContainer");
+ dojo.require("dijit.layout.ContentPane");
+ dojo.require("dijit.layout.SplitContainer");
+ </script>
+</head>
+
+<body class="tundra">
+ <h1>
+ DEMO: µjax Data Store
+ </h1>
+
+ <div dojoType="dojox.data.SlingNodeStore" url="/" jsId="nodeStore"></div>
+
+ <!-- the data store -->
+ <div dojoType="dojox.data.SlingPropertyStore" url="/test" jsId="propertyStore">
+ </div>
+
+ <div dojoType="dojox.grid.data.DojoData" jsId="model"
+ rowsPerPage="20" store="propertyStore" query="{ namespace: '*' }"
+ clientSort="true">
+ </div>
+
+ <div dojoType="dojox.grid.data.DojoData" jsId="childmodel"
+ rowsPerPage="20" store="nodeStore" query="{ level: 1 }"
+ clientSort="true">
+ </div>
+
+
+<div dojoType="dijit.layout.LayoutContainer" style="width: 100%; height: 100%; padding: 0; margin: 0; border: 0;">
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="top" style="margin:5px;">
+ <form action="/test" method="POST" dojoType="dijit.form.Form" onSubmit="alert(this);">
+ <script type="dojo/method" event="execute">
+ propertyStore.newItem(this.getValues());
+ thisGrid.refresh();
+ return false;
+ </script>
+ <input name="name" dojoType="dijit.form.TextBox" value=""><input name="value" dojoType="dijit.form.TextBox" value="">
+ <input type="submit" value="Add Property">
+ </form>
+
+ </div>
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="left"
+ style="width: 300px;overflow:auto;">
+ <div dojoType="dijit.Tree" id="tree3" store="nodeStore">
+ <script type="dojo/connect" event="onClick" args="item,node">
+ //update the store
+ propertyStore = new dojox.data.SlingPropertyStore({url: item.uri});
+ //update the model
+ model = new dojox.grid.data.DojoData(null, null, {store: propertyStore});
+ //model.setData(propertyStore);
+
+ //update the grid?
+ thisGrid.setModel(model);
+ thisGrid.refresh();
+ </script>
+ </div>
+ </div>
+ <div dojoType="dijit.layout.ContentPane" layoutAlign="client">
+
+ <div dojoType="dijit.layout.SplitContainer"
+ orientation="vertical"
+ sizerWidth="7"
+ activeSizing="true">
+ <div dojoType="dijit.layout.ContentPane" title="Properties">
+
+ <div id="grid" elasticView="2" dojoType="dojox.Grid" model="model" autoWidth="true" autoHeight="true"
+ jsId="thisGrid">
+ <script type="dojo/method">
+ var view1 = {
+ cells: [[
+ /*{name: 'URI', field:0},*/
+ {name: 'Property', field:1, width:"30em"},
+ {name: 'Value', field:2, width:"30em", editor:dojox.grid.editors.Input}
+ ]
+ ]
+ };
+ var rowbar = {
+ type: 'dojox.GridRowView', width: '20px'
+ };
+
+ // When you initialize inside the dojo/method script, you must set the
+ // structure manually.
+ var layout = [ rowbar, view1 ];
+ thisGrid.setStructure(layout);
+ </script>
+ </div>
+
+ </div>
+
+ <div dojoType="dijit.layout.ContentPane" title="Child Nodes">
+
+ <div id="childgrid" jsId="childGrid" dojoType="dojox.Grid" model="childmodel" autoWidth="true" autoHeight="true">
+
+ <script type="dojo/method">
+ var tableview = {
+ cells: [
+ [
+ {name: "URI", field: "sling:uri", width:"200px" },
+ {name: "Created", field: "jcr:created", width:"200px" },
+ {name: "Primary Type", field: "jcr:primaryType", width:"200px" }
+ ]
+ ]
+ };
+
+ childGrid.setStructure([tableview]);
+ </script>
+
+ </div>
+
+ </div>
+ </div>
+
+
+
+
+
+
+ </div>
+</div>
+
+</body>
+</html>
Propchange: incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo2.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo3.html
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo3.html?rev=637063&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo3.html (added)
+++ incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo3.html Fri Mar 14 04:22:43 2008
@@ -0,0 +1,62 @@
+<!--
+ This file is a demo of multiple dojo.data aware widgets using different datastore implementations for displaying data.
+-->
+<html>
+<head>
+ <title>Demo of Multiple Widgets using the µjax Data Store</title>
+ <style type="text/css">
+ @import "../../../dijit/themes/tundra/tundra.css";
+ @import "../../../dojo/resources/dojo.css";
+ @import "../../../dijit/tests/css/dijitTests.css";
+ @import "../../../dojox/grid/_grid/tundraGrid.css";
+ </style>
+
+ <script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true, parseOnLoad: true, usePlainJson: true, debugAtAllCosts: true"></script>
+ <script type="text/javascript">
+ dojo.require("dojo.parser");
+ dojo.require("dijit.form.ComboBox");
+ dojo.require("dijit.Tree");
+ dojo.require("dojox.data.SlingNodeStore");
+ dojo.require("dojox.data.SlingPropertyStore");
+ dojo.require("dojox.grid._data.model");
+ dojo.require("dojox.grid.Grid");
+ </script>
+</head>
+
+<body class="tundra">
+ <h1>
+ DEMO: µjax Data Store
+ </h1>
+
+ <!-- the data store -->
+ <div dojoType="dojox.data.SlingNodeStore" url="/dojo/dojo" jsId="propertyStore">
+ </div>
+
+
+
+ <h3>
+ Widgets using µjaxStore:
+ </h3>
+
+ <!-- the data model (for the grid) -->
+ <div dojoType="dojox.grid.data.DojoData" jsId="propertyModel"
+ store="propertyStore" clientSort="true" query="{ level: 2 }">
+ </div>
+
+ <script type="text/javascript">
+ var tableview = {
+ cells: [
+ [
+ {name: "URI", field: "sling:uri", width:"200px" },
+ {name: "Created", field: "jcr:created", width:"200px" },
+ {name: "Primary Type", field: "jcr:primaryType", width:"200px" }
+ ]
+ ]
+ };
+
+ var tablestructure = [ tableview ];
+ </script>
+
+ <div id="grid" dojoType="dojox.Grid" model="propertyModel" structure="tablestructure"></div>
+</body>
+</html>
Propchange: incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/SLING-INF/content/dojox/data/demo/demo3.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/dojox/data/SlingNodeStore.js
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/dojox/data/SlingNodeStore.js?rev=637063&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/dojox/data/SlingNodeStore.js (added)
+++ incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/dojox/data/SlingNodeStore.js Fri Mar 14 04:22:43 2008
@@ -0,0 +1,569 @@
+/*
+ * 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.
+ */
+if(!dojo._hasResource["dojox.data.SlingNodeStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.data.SlingNodeStore"] = true;
+
+
+dojo.provide("dojox.data.SlingNodeStore");
+
+dojo.declare("dojox.data.SlingNodeStore", null, {
+ url:"",
+ query:null,
+
+ /* summary:
+ * The SlingNodeStore implements the dojo.data.api.Read API.
+ */
+ constructor: function(/* Object */ keywordParameters){
+ this.uri = keywordParameters.url;
+ },
+
+ getValue: function( /* item */ item,
+ /* attribute-name-string */ attribute,
+ /* value? */ defaultValue){
+ console.log("getValue " + attribute);
+ if (!this.isItem(item)) {
+ throw new Error(item + " is not an item");
+ }
+ if (!dojo.isString(attribute)) {
+ throw new Error(attribute + " is not a string");
+ }
+ if (attribute=="sling:uri") {
+ return item.uri;
+ }
+ //TODO: handle child nodes and multi-value-properties
+ if (item.node[attribute]) {
+ return item.node[attribute]
+ } else if (defaultValue) {
+ return defaultValue;
+ }
+ return null;
+ },
+
+ getValues: function(/* item */ item,
+ /* attribute-name-string */ attribute){
+ //console.log("getValues");
+ if (!this.isItem(item)) {
+ throw new Error(item + " is not an item");
+ }
+ if (!dojo.isString(attribute)) {
+ throw new Error(attribute + " is not a string");
+ }
+ if (attribute=="children"&&this._hasChildren(item)) {
+ return this._getChildren(item);
+ }
+ if (item.node[attribute]) {
+ if (dojo.isArray(item.node[attribute])) {
+ return item.node[attribute]
+ } else {
+ return [item.node[attribute]];
+ }
+ } else {
+ var array = [];
+ return array; // an array that may contain literals and items
+ }
+ },
+
+ _getChildren: function(item) {
+ var children = [];
+
+ for (var property in item.node) {
+ if (dojo.isObject(item.node[property])) {
+ if (item.node[property]["jcr:primaryType"]&&this.accept(item.node[property], item.query)) {
+ var childuri = item.uri=="/" ? "/" + property : item.uri + "/" + property;
+ var child = {uri: childuri, query: item.query }
+ children.push(child);
+ }
+ }
+ }
+ //console.log("children: ");
+ //console.dir(children);
+ return children;
+ },
+
+ getAttributes: function(/* item */ item){
+ console.log("getAttributes");
+ if (!this.isItem(item)) {
+ return [];
+ }
+ var array = [];
+ var children = false;
+
+ for (var property in item.node) {
+ if (!dojo.isObject(item.node[property])) {
+ array.push(property);
+ } else {
+ children = true;
+ }
+ }
+ if (children) {
+ array.push("children");
+ }
+ array.push("sling:uri");
+
+ return array; // array
+ },
+
+ hasAttribute: function( /* item */ item,
+ /* attribute-name-string */ attribute){
+ //console.log("hasAttribute " + attribute);
+ if (!this.isItem(item)) {
+ throw new Error(item + " is not an item");
+ }
+ if (!dojo.isString(attribute)) {
+ throw new Error(attribute + " is not a string");
+ }
+ if (attribute=="children") {
+ return this._hasChildren(item);
+ }
+ if (item.node[attribute]) {
+ return true;
+ }
+ return false;
+ },
+
+ _hasChildren: function(/* item */ item) {
+ //children are all properties of a node that are objects
+ for (var property in item.node) {
+ if (dojo.isObject(item.node[property])) {
+ if (item.node[property]["jcr:primaryType"]&&this.accept(item.node[property], item.query)) {
+ //console.log("there are children");
+ return true;
+ }
+ }
+ }
+ //console.log("there are no children");
+ return false;
+ },
+
+ containsValue: function(/* item */ item,
+ /* attribute-name-string */ attribute,
+ /* anything */ value){
+ //console.log("containsValue");
+ if (!this.isItem(item)) {
+ throw new Error(item + " is not an item");
+ }
+
+ //TODO: handle child nodes
+ for (var property in item.node) {
+ if (item.node[property]==value) {
+ return true;
+ }
+ }
+ return false;
+ },
+
+ /*
+ var anitem = {uri: "http://localhost:8888/1.json", node: null};
+
+ */
+ isItem: function(/* anything */ something) {
+ if (!something) {
+ return false;
+ }
+ if (something.uri) {
+ return true;
+ }
+ return false;
+ },
+
+ isItemLoaded: function(something) {
+ //console.log("isItemLoaded");
+ if (!this.isItem(something)) {
+ return false;
+ }
+ if (something.node) {
+ return true;
+ }
+ return false;
+ },
+
+ loadItem: function(/* object */ keywordArgs) {
+ //console.log("loadItem");
+ if (this.isItem(keywordArgs.item)) {
+ //console.log("loading " + keywordArgs.item.uri);
+ var url = keywordArgs.item.uri + ".1.json";
+
+ var xhr = dojo.xhrGet({
+ url: url,
+ handleAs: "json-comment-optional",
+ load: function(response, ioargs) {
+ //console.dir(response);
+
+ var item = keywordArgs.item;
+ item.node = response;
+ //console.log("filtering...");
+
+ if (keywordArgs.onItem) {
+ if (keywordArgs.scope) {
+ keywordArgs.onItem.call(keywordArgs.scope, item)
+ } else {
+ keywordArgs.onItem(item);
+ }
+ }
+
+ },
+ error: function(error) {
+ if (keywordArgs.onError) {
+ if (keywordArgs.scope) {
+ keywordArgs.onError.call(keywordArgs.scope, error)
+ } else {
+ keywordArgs.onError(error);
+ }
+ }
+ }
+ });
+ } else {
+ if (keywordArgs.onError) {
+ //todo: respect scope
+ if (keywordArgs.scope) {
+ keywordArgs.onError.call(keywordArgs.scope, "no item to load");
+ } else {
+ keywordArgs.onError("no item to load");
+ }
+
+ }
+ }
+ },
+
+ _fetchItems: function( /* Object */ keywordArgs,
+ /* Function */ findCallback,
+ /* Function */ errorCallback) {
+ var request = keywordArgs;
+
+ var xhr;
+
+ request.abort = function() {
+ if (xhr.abort) {
+ xhr.abort();
+ }
+ };
+ var query = keywordArgs.query;
+
+ var depth = 1;
+ if (query&&query.level) {
+ depth = depth + query.level;
+ }
+ var url = this.uri + "."+depth+".json";
+ var that = this;
+
+ xhr = dojo.xhrGet({
+ url: url,
+ handleAs: "json-comment-optional",
+ load: function(response, ioargs) {
+ var item = { node: response, uri: that.uri};
+
+ var items = [];
+ if (request.onComplete) {
+ if (query&&query.level) {
+ //console.log("hehe. got a level");
+ var checkitems = [ { node: item.node, uri: that.uri } ];
+ items = that.descend(checkitems, query.level);
+ } else {
+ if (that.accept(item.node, query)) {
+ item.query = query;
+ items.push(item);
+ }
+ }
+ findCallback(items, keywordArgs);
+ }
+ }
+ });
+ },
+
+ descend: function(items, level) {
+ var allitems = [];
+ console.log(level);
+ if (level==0) {
+ allitems = allitems.concat(items);
+ } else {
+ var newitems = [];
+ for (var i=0;i<items.length;i++) {
+ var item = items[i];
+ for (var property in item.node) {
+ if (dojo.isObject(item.node[property])) {
+ var newitem = { node: item.node[property], uri: ( item.uri == "/" ? "" : item.uri ) + "/" + property };
+ newitems.push(newitem);
+ }
+ }
+ }
+ allitems = allitems.concat(this.descend(newitems, level - 1));
+ }
+ console.dir(allitems);
+ return allitems;
+ },
+
+ _nofetch: function(/* object */ keywordArgs) {
+ var request = keywordArgs;
+
+ var xhr;
+
+ request.abort = function() {
+ if (xhr.abort) {
+ xhr.abort();
+ }
+ };
+
+
+ var query = keywordArgs.query;
+
+ var depth = 1;
+ if (query.level) {
+ depth = depth + query.level;
+ }
+ var url = this.uri + "."+depth+".json";
+ var that = this;
+
+ xhr = dojo.xhrGet({
+ url: url,
+ handleAs: "json-comment-optional",
+ load: function(response, ioargs) {
+ var item = { node: response, uri: that.uri};
+
+ if (request.onComplete) {
+ if (query.level) {
+
+ } else {
+ if (that.accept(item.node, query)) {
+ item.query = query;
+ request.onComplete([ item ], request);
+ }
+ }
+ }
+ }
+ });
+ //TODO: implement
+ //alert(this.url);
+ return request;
+ },
+
+ accept: function(node, query) {
+ //TODO: handle querying for arrays
+ if (!query) {
+ return true;
+ }
+ if (!query.query) {
+ return true;
+ }
+ for (var property in query.query) {
+ //console.log(property);
+ if (node[property]) {
+ if (dojo.isArray(query.query[property])) {
+ //console.log("multiple values possible");
+ var onematch = false;
+ for (var value in query.query[property]) {
+ //console.log("checking value " + query.query[property][value]);
+ if (node[property]==query.query[property][value]) {
+ onematch = true;
+ }
+ }
+ if (!onematch) {
+ //console.log("required property " + property + " has wrong value "+ node[property]);
+ return false;
+ }
+ } else {
+ if (node[property]!=query.query[property]) {
+ //console.log("required property " + property + " has wrong value "+ node[property]);
+ return false;
+ }
+ }
+ } else {
+ //console.log("required property " + property + " missing");
+ return false;
+ }
+ }
+ return true;
+ },
+
+ getFeatures: function() {
+ return {
+ "dojo.data.api.Read": true,
+ 'dojo.data.api.Write': true,
+ 'dojo.data.api.Identity': true,
+ 'dojo.data.api.Notification': true
+ };
+ },
+
+ close: function(/*dojo.data.api.Request || keywordArgs || null */ request) {
+ //nothing to do here
+ },
+
+ getLabel: function(/* item */ item) {
+ //TODO: use item.node["title"] or item.node["jcr:title"]
+ if (item["jcr:title"]) {
+ return item["jcr:title"];
+ }
+ if (item["title"]) {
+ return item["title"];
+ }
+ if (item.uri.length==1) {
+ return "/"
+ } else {
+ return item.uri.replace(/.*\//,"")
+ }
+ },
+
+ getLabelAttributes: function(/* item */ item) {
+ //TODO: use item.node["title"] or item.node["jcr:title"]
+ return [];
+ },
+
+
+ //dojo.data.api.Identity functions
+
+ getIdentity: function(/* item */ item) {
+ //console.log("getIdentity");
+ if (!this.isItem(item)) {
+ throw new Error(item + " is not an item");
+ }
+ return item.uri;
+ },
+
+ getIdentityAttributes: function(/* item */ item) {
+ //console.log("getIdentityAttributes");
+ //identity depends on the URI, not the representation
+ return null;
+ },
+
+ fetchItemByIdentity: function(/* object */ keywordArgs) {
+ // keywordArgs:
+ // An anonymous object that defines the item to locate and callbacks to invoke when the
+ // item has been located and load has completed. The format of the object is as follows:
+ // {
+ // identity: string|object,
+ // onItem: Function,
+ // onError: Function,
+ // scope: object
+ // }
+
+ //TODO: implement
+ },
+
+
+ //dojo.data.api.Write functions
+
+ newItem: function(/* Object? */ keywordArgs, /*Object?*/ parentInfo) {
+ console.log("newItem");
+ var item = keywordArgs;
+ var that = this;
+
+ var xhr = xhr = dojo.xhrPost({
+ url: item.uri,
+ content: item,
+ load: function(response, ioargs) {
+ item.dirty = false;
+ console.log("onNew");
+ that.onNew(item, null);
+ }
+ });
+ return item;
+ },
+
+ deleteItem: function(/* item */ item) { console.log("deleteItem");
+ throw new Error('Unimplemented API: dojo.data.api.Write.deleteItem');
+ console.log("deleteItem");
+ return false; // boolean
+ },
+
+ setValue: function( /* item */ item,
+ /* string */ attribute,
+ /* almost anything */ value) {
+ console.log("setValue");
+ //you can only set the value of an item, so
+ var oldvalue = item[attribute];
+ item[attribute] = value;
+ var that = this;
+
+ var xhr = xhr = dojo.xhrPost({
+ url: item.uri,
+ content: item,
+ load: function(response, ioargs) {
+ that.onSet(item, attribute, oldvalue, value);
+ }
+ });
+ },
+
+
+ setValues: function(item, attribute, values) { console.log("setValues");
+ throw new Error('Unimplemented API: dojo.data.api.Write.setValues');
+ this.onSet(item, attribute, oldvalues, values);
+ },
+
+ unsetAttribute: function( /* item */ item,
+ /* string */ attribute){
+ // summary:
+ // Deletes all the values of an attribute on an item.
+ //
+ // item:
+ // The item to modify.
+ // attribute:
+ // The attribute of the item to unset represented as a string.
+ //
+ // exceptions:
+ // Throws an exception if *item* is not an item, or if *attribute*
+ // is neither an attribute object or a string.
+ // example:
+ // | var success = store.unsetAttribute(kermit, "color");
+ // | if (success) {assert(!store.hasAttribute(kermit, "color"));}
+ throw new Error('Unimplemented API: dojo.data.api.Write.unsetAttribute');
+ return false; // boolean
+ },
+
+ save: function(/* object */ keywordArgs) { console.log("save");
+ console.log("save");
+ },
+
+ revert: function(){ console.log("revert");
+ throw new Error('Unimplemented API: dojo.data.api.Write.revert');
+ return false; // boolean
+ },
+
+ isDirty: function(/* item? */ item) { console.log("isDirty");
+ return false;
+ },
+
+ // Notification API
+
+ onSet: function(/* item */ item,
+ /*attribute-name-string*/ attribute,
+ /*object | array*/ oldValue,
+ /*object | array*/ newValue){
+ // summary: See dojo.data.api.Notification.onSet()
+
+ // No need to do anything. This method is here just so that the
+ // client code can connect observers to it.
+ },
+
+ onNew: function(/* item */ newItem, /*object?*/ parentInfo){
+ // summary: See dojo.data.api.Notification.onNew()
+
+ // No need to do anything. This method is here just so that the
+ // client code can connect observers to it.
+ },
+
+ onDelete: function(/* item */ deletedItem){
+ // summary: See dojo.data.api.Notification.onDelete()
+
+ // No need to do anything. This method is here just so that the
+ // client code can connect observers to it.
+ }
+
+});
+
+dojo.extend(dojox.data.SlingNodeStore,dojo.data.util.simpleFetch);
+
+}
+
Propchange: incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/dojox/data/SlingNodeStore.js
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/dojox/data/SlingPropertyStore.js
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/dojox/data/SlingPropertyStore.js?rev=637063&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/dojox/data/SlingPropertyStore.js (added)
+++ incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/dojox/data/SlingPropertyStore.js Fri Mar 14 04:22:43 2008
@@ -0,0 +1,401 @@
+/*
+ * 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.
+ */
+if(!dojo._hasResource["dojox.data.SlingPropertyStore"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.data.SlingPropertyStore"] = true;
+
+
+dojo.provide("dojox.data.SlingPropertyStore");
+
+dojo.declare("dojox.data.SlingPropertyStore", null, {
+ url:"",
+ query:null,
+
+ /* summary:
+ * The SlingPropertyStore implements the dojo.data.api.Read API.
+ * It will return one data item for every property found
+ */
+ constructor: function(/* Object */ keywordParameters){ console.log("constructor");
+ this.uri = keywordParameters.url;
+ },
+
+ getValue: function( /* item */ item, /* attribute-name-string */ attribute, /* value? */ defaultValue){
+ //console.log("getValue " + attribute + " " + item.name);
+ if (!this.isItem(item)) {
+ throw new Error(item + " is not an item");
+ }
+ if (!dojo.isString(attribute)) {
+ throw new Error(attribute + " is not a string");
+ }
+ return item[attribute];
+ },
+
+ getValues: function(/* item */ item, /* attribute-name-string */ attribute){ console.log("getValues");
+ //console.log("getValues");
+ if (!this.isItem(item)) {
+ throw new Error(item + " is not an item");
+ }
+ if (!dojo.isString(attribute)) {
+ throw new Error(attribute + " is not a string");
+ }
+ return item[attribute];
+ },
+
+ getAttributes: function(/* item */ item){ //console.log("getAttributes");
+ //console.log("getAttributes");
+ if (!this.isItem(item)) {
+ throw new Error(item + " is not an item");
+ }
+ var array = [];
+ for (var property in item) {
+ array.push(property);
+ }
+
+ return array; // array
+ },
+
+ hasAttribute: function( /* item */ item, /* attribute-name-string */ attribute){ console.log("hasAttribute");
+ //console.log("hasAttribute " + attribute);
+ if (!this.isItem(item)) {
+ throw new Error(item + " is not an item");
+ }
+ if (!dojo.isString(attribute)) {
+ throw new Error(attribute + " is not a string");
+ }
+ return item[attribute];
+ },
+
+ containsValue: function(/* item */ item, /* attribute-name-string */ attribute, /* anything */ value){ console.log("containsValue");
+ //console.log("containsValue");
+ if (!this.isItem(item)) {
+ throw new Error(item + " is not an item");
+ }
+
+ //TODO: handle child nodes
+ for (var property in item) {
+ if (item[property]==value) {
+ return true;
+ }
+ }
+ return false;
+ },
+
+ /*
+ var anitem = {uri: "http://localhost:8888/1.json", node: null};
+
+ */
+ isItem: function(/* anything */ something) {
+ //console.log("isItem " + something.uri);
+ if (something.uri) {
+ return true;
+ }
+ return false;
+ },
+
+ isItemLoaded: function(something) { console.log("isItemLoaded");
+ return true;
+ },
+
+ loadItem: function(/* object */ keywordArgs) { console.log("loadItem");
+ return;
+ },
+
+ _fetchItems: function( /* Object */ keywordArgs,
+ /* Function */ findCallback,
+ /* Function */ errorCallback) {
+ var request = keywordArgs;
+
+ var xhr;
+
+ request.abort = function() {
+ errorCallback.("XHR aborted", keywordArgs)
+ };
+
+ var depth = 1;
+
+ var url = this.uri + "."+depth+".json";
+ var that = this;
+
+ var query = keywordArgs.query;
+
+ xhr = dojo.xhrGet({
+ url: url,
+ handleAs: "json-comment-optional",
+ load: function(response, ioargs) {
+ var items = [];
+ for (var property in response) {
+ if (!dojo.isObject(response[property])) {
+ //console.debug(property);
+ items.push({ uri: that.uri, name: property, value: response[property]});
+ }
+ }
+ findCallback(items, keywordArgs);
+ }
+ });
+
+ },
+
+ _nofetch: function(/* object */ keywordArgs) { console.log("fetch");
+ var request = keywordArgs;
+
+ var xhr;
+
+ request.abort = function() {
+ if (xhr.abort) {
+ xhr.abort();
+ }
+ };
+
+ var depth = 1;
+
+ /*
+ if (keywordArgs.count) {
+ depth = keywordArgs.count;
+ }
+ */
+
+ var url = this.uri + "."+depth+".json";
+ var that = this;
+
+ var query = keywordArgs.query;
+
+ xhr = dojo.xhrGet({
+ url: url,
+ handleAs: "json-comment-optional",
+ load: function(response, ioargs) { console.log("load");
+ //console.dir(response);
+ var items = [];
+
+ for (var property in response) {
+ if (!dojo.isObject(response[property])) {
+ //console.debug(property);
+ items.push({ uri: that.uri, name: property, value: response[property]});
+ }
+ }
+
+ if (request.onComplete) {
+ if (request.scope) {
+ request.onComplete.call(request.scope, item. request)
+ } else {
+ request.onComplete(items, request);
+ }
+ //request.onComplete(items, request);
+ }
+ }
+ });
+ //TODO: implement
+ //alert(this.url);
+ return request;
+ },
+
+
+ getFeatures: function() { console.log("getFeatures");
+ console.log("getFeatures");
+ return {
+ "dojo.data.api.Read": true,
+ 'dojo.data.api.Write': true,
+ 'dojo.data.api.Identity': true,
+ 'dojo.data.api.Notification': true
+ };
+ },
+
+ close: function(/*dojo.data.api.Request || keywordArgs || null */ request) { console.log("close");
+ //nothing to do here
+ },
+
+ getLabel: function(/* item */ item) { console.log("getLabel");
+ if (item.uri.length==1) {
+ return "/"
+ } else {
+ return item.uri.replace(/.*\//,"")
+ }
+ },
+
+ getLabelAttributes: function(/* item */ item) { console.log("getLabelAttributes");
+ //TODO: use item.node["title"] or item.node["jcr:title"]
+ return ["uri"];
+ },
+
+ //dojo.data.api.Identity functions
+
+ getIdentity: function(/* item */ item) { //console.log("getIdentity");
+ //console.log("getIdentity");
+ if (!this.isItem(item)) {
+ console.log("error: not an item");
+ throw new Error(item + " is not an item");
+ }
+ return item.uri + "[" + item.name + "]";
+ },
+
+ getIdentityAttributes: function(/* item */ item) { console.log("getIdentityAttributes");
+ //console.log("getIdentityAttributes");
+ //identity depends on the URI, not the representation
+ return ["uri", "name"];
+ },
+
+ fetchItemByIdentity: function(/* object */ keywordArgs) { console.log("fetchItemByIdentity");
+ // keywordArgs:
+ // An anonymous object that defines the item to locate and callbacks to invoke when the
+ // item has been located and load has completed. The format of the object is as follows:
+ // {
+ // identity: string|object,
+ // onItem: Function,
+ // onError: Function,
+ // scope: object
+ // }
+
+ //TODO: implement
+ },
+
+
+ //dojo.data.api.Write functions
+
+ newItem: function(/* Object? */ keywordArgs, /*Object?*/ parentInfo) {
+ console.log("newItem");
+ var item = keywordArgs;
+ item.uri = this.uri;
+ item.dirty = true;
+
+ content = {};
+ content[item.name] = item.value;
+
+ var that = this;
+
+ var xhr = xhr = dojo.xhrPost({
+ url: item.uri,
+ content: content,
+ load: function(response, ioargs) {
+ item.dirty = false;
+ console.log("onNew");
+ that.onNew(item, null);
+ }
+ });
+
+ return item;
+ },
+
+ deleteItem: function(/* item */ item) { console.log("deleteItem");
+ throw new Error('Unimplemented API: dojo.data.api.Write.deleteItem');
+ console.log("deleteItem");
+ return false; // boolean
+ },
+
+ setValue: function( /* item */ item,
+ /* string */ attribute,
+ /* almost anything */ value) {
+ console.log("setValue");
+ //you can only set the value of an item, so
+
+ var oldvalue = item.value;
+
+ item.value = value;
+ item.dirty = true;
+
+ content = {};
+ content[item.name] = item.value;
+
+ var that = this;
+
+ var xhr = xhr = dojo.xhrPost({
+ url: item.uri,
+ content: content,
+ load: function(response, ioargs) {
+ item.dirty = false;
+ that.onSet(item, attribute, oldvalue, value);
+ }
+ });
+
+ },
+
+ setValues: function(item, attribute, values) { console.log("setValues");
+ console.log("setValues");
+ var oldvalues = item.values;
+ item.value = values;
+ item.dirty = true;
+
+ this.onSet(item, attribute, oldvalues, values);
+ },
+
+ unsetAttribute: function( /* item */ item,
+ /* string */ attribute){
+ // summary:
+ // Deletes all the values of an attribute on an item.
+ //
+ // item:
+ // The item to modify.
+ // attribute:
+ // The attribute of the item to unset represented as a string.
+ //
+ // exceptions:
+ // Throws an exception if *item* is not an item, or if *attribute*
+ // is neither an attribute object or a string.
+ // example:
+ // | var success = store.unsetAttribute(kermit, "color");
+ // | if (success) {assert(!store.hasAttribute(kermit, "color"));}
+ throw new Error('Unimplemented API: dojo.data.api.Write.unsetAttribute');
+ return false; // boolean
+ },
+
+ save: function(/* object */ keywordArgs) { console.log("save");
+ console.log("save");
+ },
+
+ revert: function(){ console.log("revert");
+ throw new Error('Unimplemented API: dojo.data.api.Write.revert');
+ return false; // boolean
+ },
+
+ isDirty: function(/* item? */ item) { console.log("isDirty");
+ if (item.dirty) {
+ return item.dirty;
+ }
+ return false;
+ },
+
+ // Notification API
+
+ onSet: function(/* item */ item,
+ /*attribute-name-string*/ attribute,
+ /*object | array*/ oldValue,
+ /*object | array*/ newValue){
+ // summary: See dojo.data.api.Notification.onSet()
+
+ // No need to do anything. This method is here just so that the
+ // client code can connect observers to it.
+ },
+
+ onNew: function(/* item */ newItem, /*object?*/ parentInfo){
+ // summary: See dojo.data.api.Notification.onNew()
+
+ // No need to do anything. This method is here just so that the
+ // client code can connect observers to it.
+ },
+
+ onDelete: function(/* item */ deletedItem){
+ // summary: See dojo.data.api.Notification.onDelete()
+
+ // No need to do anything. This method is here just so that the
+ // client code can connect observers to it.
+ }
+
+
+
+});
+
+dojo.extend(dojox.data.SlingPropertyStore,dojo.data.util.simpleFetch);
+
+}
+
Propchange: incubator/sling/trunk/extensions/dojo-ujax/src/main/resources/dojox/data/SlingPropertyStore.js
------------------------------------------------------------------------------
svn:eol-style = native