Sling
  1. Sling
  2. SLING-301

Dojo Classes for accessing the repository via the µjax protocol

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Servlets
    • Labels:
      None

      Description

      I've created two Dojo Store implementations that use the µjax protocol to communicate with the repository. The UJaxNodeStore implements a read-only hierarchical store (I am planning to add write support later on) that can be used to read properties and children of a node. The UJaxPropertyStore implements a read-write flat store for accessing the properties of a node. The Store showcases a high-level integration with a full-fledged AJAX toolkit that allows easy integration with an existing widget system.

      Using these store classes, it was easy to create an example repository browser that uses a tree control and a grid control to browse the resource tree and allows to create new and change existing properties.

      1. dojo-ujax.tar.gz
        4.21 MB
        Lars Trieloff
      2. SlingNodeStore.js
        15 kB
        Lars Trieloff
      3. SlingPropertyStore.js
        11 kB
        Lars Trieloff
      4. demo2.html
        5 kB
        Lars Trieloff
      5. demo4.html
        2 kB
        Lars Trieloff
      6. demo.html
        3 kB
        Lars Trieloff
      7. dojo.sling.patch.20081221.zip
        14 kB
        Rory Douglas

        Issue Links

          Activity

          Hide
          Lars Trieloff added a comment -

          This is the current snapshot I am going to showcase tomorrow at Web Monday Stockholm. In order to get it working you have to
          1. create a node test with type nt:unstructured
          2. ensure that the user is authenticated to be able to write properties. (the best way to do this right now is to configure the anonymous user to be admin, as sling will not ask for authentication, but silently fail.)

          Show
          Lars Trieloff added a comment - This is the current snapshot I am going to showcase tomorrow at Web Monday Stockholm. In order to get it working you have to 1. create a node test with type nt:unstructured 2. ensure that the user is authenticated to be able to write properties. (the best way to do this right now is to configure the anonymous user to be admin, as sling will not ask for authentication, but silently fail.)
          Hide
          Tobias Bocanegra added a comment -

          > 2). ensure that the user is authenticated to be able to write properties. (the best way to do this right
          > now is to configure the anonymous user to be admin, as sling will not ask for authentication, but
          > silently fail.)

          or configure the repository so that the anonymous user has write access.

          Show
          Tobias Bocanegra added a comment - > 2). ensure that the user is authenticated to be able to write properties. (the best way to do this right > now is to configure the anonymous user to be admin, as sling will not ask for authentication, but > silently fail.) or configure the repository so that the anonymous user has write access.
          Hide
          Felix Meschberger added a comment -

          I think this is a worth while contribution. We should separate the ujax-procotol support for dojo and the dojo library itself into two bundles to be able to manage it better. See also SLING-302

          Show
          Felix Meschberger added a comment - I think this is a worth while contribution. We should separate the ujax-procotol support for dojo and the dojo library itself into two bundles to be able to manage it better. See also SLING-302
          Hide
          Felix Meschberger added a comment -

          This issue depends on SLING-302 being fixed to provide the dojo toolkit.

          Show
          Felix Meschberger added a comment - This issue depends on SLING-302 being fixed to provide the dojo toolkit.
          Hide
          Felix Meschberger added a comment -

          Lars could you please create an attachement which just contains your extensions to the standard Dojo ? Thanks.

          Show
          Felix Meschberger added a comment - Lars could you please create an attachement which just contains your extensions to the standard Dojo ? Thanks.
          Hide
          Lars Trieloff added a comment -

          to be placed at /dojo/dojox/data

          Updated the node store to the new naming regulation and it supports querying only child nodes of a node, which is very helpful if you want to get a tabular list of child nodes and their properties. Also: write support added.

          Show
          Lars Trieloff added a comment - to be placed at /dojo/dojox/data Updated the node store to the new naming regulation and it supports querying only child nodes of a node, which is very helpful if you want to get a tabular list of child nodes and their properties. Also: write support added.
          Hide
          Lars Trieloff added a comment -

          Updated the naming, that's all. To be placed at /dojo/dojox/data

          Show
          Lars Trieloff added a comment - Updated the naming, that's all. To be placed at /dojo/dojox/data
          Hide
          Lars Trieloff added a comment -

          to be placed (optionally) at /dojo/dojox/data/demo

          Complex example showing tree browser and two grids using the NodeStore in action.

          Show
          Lars Trieloff added a comment - to be placed (optionally) at /dojo/dojox/data/demo Complex example showing tree browser and two grids using the NodeStore in action.
          Hide
          Lars Trieloff added a comment -

          to be placed (optionally) at /dojo/dojox/data/demo

          simple example showing how to use the query="

          {level : 2}

          " parameter on node stores to get a table view of child nodes.

          Show
          Lars Trieloff added a comment - to be placed (optionally) at /dojo/dojox/data/demo simple example showing how to use the query=" {level : 2} " parameter on node stores to get a table view of child nodes.
          Hide
          Lars Trieloff added a comment -

          to be placed (optionally) at /dojo/dojox/data/demo

          simple example showing how to use queries in the NodeStore.

          Show
          Lars Trieloff added a comment - to be placed (optionally) at /dojo/dojox/data/demo simple example showing how to use queries in the NodeStore.
          Hide
          Felix Meschberger added a comment -

          Committed the scripts and demos to the new extensions/dojo-ujax module in Rev. 637063.

          The scripts are provided as BundleResources, that is they are not copied into the repository. The demo content on the other hand is copied to the repository to be able to "play" with it.

          I think, this issue can be resolved. Please close if you agree. Thanks.

          Show
          Felix Meschberger added a comment - Committed the scripts and demos to the new extensions/dojo-ujax module in Rev. 637063. The scripts are provided as BundleResources, that is they are not copied into the repository. The demo content on the other hand is copied to the repository to be able to "play" with it. I think, this issue can be resolved. Please close if you agree. Thanks.
          Hide
          Lars Trieloff added a comment -

          Thank you.

          Show
          Lars Trieloff added a comment - Thank you.
          Hide
          Vidar S. Ramdal added a comment -

          Lars Trieloff - 13/Mar/08: "Also: write support added."

          Where exactly is the write support added? I find no traces of write support in SlingNodeStore.js. E.g, SlingNodeStore.js#500:

          setValues: function(item, attribute, values) { console.log("setValues");
          throw new Error('Unimplemented API: dojo.data.api.Write.setValues');
          ...

          Show
          Vidar S. Ramdal added a comment - Lars Trieloff - 13/Mar/08: "Also: write support added." Where exactly is the write support added? I find no traces of write support in SlingNodeStore.js. E.g, SlingNodeStore.js#500: setValues: function(item, attribute, values) { console.log("setValues"); throw new Error('Unimplemented API: dojo.data.api.Write.setValues'); ...
          Hide
          Rory Douglas added a comment -

          The current store implementations don't work well with some common widgets (in particular ComboBox and FilteringSelect), in latest 1.2 Dojo releases.

          There are 2 problems: one, these widgets use the "query" parameter to pass a wildcarded fragment of user input to accomplish the autocomplete feature, but the SlingNodeStore/SlingPropertyStore currently only do exact string matches against the query; and two, this autocomplete query overwrites the filtering query specified on the store itself, when it really should be merged/ANDed with it.

          I've fixed the 2 classes to accomodate these wildcard queries (copied code from ItemFileReadStore). I've also made some changes/enhancements to the SlingNodeStore :

          1) Moved 'level' out of 'query', put it in optional 'queryOptions' param instead (and renamed to 'depth')

          2) Use common 'queryOptions' parameters 'deep' (along with 'depth') to control how hierarchy below target node is returned
          2)a)If 'deep' is true, return all nodes below target up to 'depth'. If 'depth' not specified, use 'infinity'.
          b)If 'deep' is false, return only nodes at 'depth' below target node. If 'depth' not specified, use 1.

          So, with the following hierarchy, and store url="/test"

          /samplenodes
          /content/
          /list1
          /nodeA
          /subNodeA
          /list2
          /nodeB
          /data
          /nodeC

          deep=true, depth=2 gives [samplenodes,content,list1,nodeA,list2,nodeB,nodeC,data]
          deep=true, no depth gives [samplenodes,content,list1,nodeA,subNodeA,nodeB,list2,nodeC,data]
          deep=false, depth=2 gives [nodeA,nodeB]
          deep=false, no depth gives [samplenodes]

          The behavior is consistent when used with ComboBox, but a little weird for Trees (where deep=false is default). Overriding deep to true for a tree can put the same node into the tree multiple times at different levels. Setting a depth for a ComboBox with deep=false sets the level from which nodes are retrieved, but for a Tree it only sets the depth at which the tree starts, it doesn't actually restrict the depth of the tree. So I've added another property 'treeDepth' (set in 'overrideDepth') which sets the the tree depth limit. This parameter has no effect on ComboBoxes since it's only enforced in the get/hasChildren methods.

          3) Added attributes 'overrideDeep' and 'overrideDepth' to enable store to override values passed in via 'queryOptions' for 'deep' and 'depth'. Primarily useful since 'deep' defaults to 'false' for DataStores, but is hard-coded to 'true' in requests from ComboBox.

          4) Merged specified store query with incoming queries from widgets before executing feth

          5) Added attributes 'statement' and 'searchprops' to enable specifying a search query for the JsonQueryServlet, rather than a JsonRendererServlet URL.

          The modified files are attached as a zip (dojo.sling.patch.20081221.zip). Also includes a new demo page (demo4.html) and a set of sample nodes (samplenodes.json) used by the demo.

          Show
          Rory Douglas added a comment - The current store implementations don't work well with some common widgets (in particular ComboBox and FilteringSelect), in latest 1.2 Dojo releases. There are 2 problems: one, these widgets use the "query" parameter to pass a wildcarded fragment of user input to accomplish the autocomplete feature, but the SlingNodeStore/SlingPropertyStore currently only do exact string matches against the query; and two, this autocomplete query overwrites the filtering query specified on the store itself, when it really should be merged/ANDed with it. I've fixed the 2 classes to accomodate these wildcard queries (copied code from ItemFileReadStore). I've also made some changes/enhancements to the SlingNodeStore : 1) Moved 'level' out of 'query', put it in optional 'queryOptions' param instead (and renamed to 'depth') 2) Use common 'queryOptions' parameters 'deep' (along with 'depth') to control how hierarchy below target node is returned 2)a)If 'deep' is true, return all nodes below target up to 'depth'. If 'depth' not specified, use 'infinity'. b)If 'deep' is false, return only nodes at 'depth' below target node. If 'depth' not specified, use 1. So, with the following hierarchy, and store url="/test" /samplenodes /content/ /list1 /nodeA /subNodeA /list2 /nodeB /data /nodeC deep=true, depth=2 gives [samplenodes,content,list1,nodeA,list2,nodeB,nodeC,data] deep=true, no depth gives [samplenodes,content,list1,nodeA,subNodeA,nodeB,list2,nodeC,data] deep=false, depth=2 gives [nodeA,nodeB] deep=false, no depth gives [samplenodes] The behavior is consistent when used with ComboBox, but a little weird for Trees (where deep=false is default). Overriding deep to true for a tree can put the same node into the tree multiple times at different levels. Setting a depth for a ComboBox with deep=false sets the level from which nodes are retrieved, but for a Tree it only sets the depth at which the tree starts, it doesn't actually restrict the depth of the tree. So I've added another property 'treeDepth' (set in 'overrideDepth') which sets the the tree depth limit. This parameter has no effect on ComboBoxes since it's only enforced in the get/hasChildren methods. 3) Added attributes 'overrideDeep' and 'overrideDepth' to enable store to override values passed in via 'queryOptions' for 'deep' and 'depth'. Primarily useful since 'deep' defaults to 'false' for DataStores, but is hard-coded to 'true' in requests from ComboBox. 4) Merged specified store query with incoming queries from widgets before executing feth 5) Added attributes 'statement' and 'searchprops' to enable specifying a search query for the JsonQueryServlet, rather than a JsonRendererServlet URL. The modified files are attached as a zip (dojo.sling.patch.20081221.zip). Also includes a new demo page (demo4.html) and a set of sample nodes (samplenodes.json) used by the demo.
          Hide
          Rory Douglas added a comment -

          Updates to SlingNodeStore & SlingPropertyStore to work with Dojo 1.2, plus feature enhancements

          Show
          Rory Douglas added a comment - Updates to SlingNodeStore & SlingPropertyStore to work with Dojo 1.2, plus feature enhancements
          Hide
          Felix Meschberger added a comment -

          Thanks for submitting this patch.

          I have created new issue SLING-792 for this enhancement.

          Show
          Felix Meschberger added a comment - Thanks for submitting this patch. I have created new issue SLING-792 for this enhancement.

            People

            • Assignee:
              Felix Meschberger
              Reporter:
              Lars Trieloff
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development