DWR Data Store

View: New views
2 Messages — Rating Filter:   Alert me  

DWR Data Store

by Joe Walker-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

I've just done a development build of DWR that includes an implementation of a Dojo Data Store that uses DWR.
If you want a quick go, download the demo WAR file from here:
- https://dwr.dev.java.net/servlets/ProjectDocumentList?folderID=9448

Drop this into tomcat/jetty/etc and browse to:
- http://localhost:8080/dwr/widgets/dojo-demo.html

This shows of a set of 100,000 people in a table which supports sorting and paging.

What do you need?

<script type="text/javascript" src="DwrStore.js"> </script>
<script>
dojo.require(blahblah);
function init() {
  var store = new DwrStore("testServerData");
  var model = new dojox.grid.data.DojoData();
  model.store = store;
  var grid = dijit.byId("grid");
  grid.setStructure(blahblah);
  grid.setModel(model);
  grid.refresh();
}
dojo.addOnLoad(init);
</script>
<!-- other imports -->
<div id="grid" dojoType="dojox.Grid" autoWidth="true"></div>

And then on the server:

MapStoreProvider<Person> provider = new MapStoreProvider<Person>(Person.class);
Map<String, Person> crowd = provider.asMap();
for (int i = 0; i < 100000; i++) {
    crowd.put(getNextId(), getRandomPerson());
}
Directory.register("testServerData", provider);

I started with 10 million people but that OOMed the JVM, so I backed off to 1million, which made dojo/firefox die. We appear to be good with 100000.

There are a number of parts to this. A server-side Directory that holds a set of StoreProviders. In the example above, the client and the server use the directory to co-ordinate the use of a data store called "testServerData". The StoreProvider interface can be implemented a number of ways. We provide a MapStoreProvider and I've got a prototype SqlStoreProvider that demonstrates that this could work on top of a database rather than a Map.
The client side of DWR then provides a interface that can used potentially by things other than a Dojo data store (see then end of engine.js). There is also a DwrStore.js that calls this API and implements Read/Identity/Notification. I'll be shaking the bugs out of Notification and finishing Write soon.

Feedback welcome - particularly, there are a number of TODO items in DwrStore.js, many of which are questions that I need to get sorted

Joe.


Re: [Dojo-interest] DWR Data Store

by jaredj :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Oh wow.  This sounds really cool.  :-)

-- Jared


On Fri, Jun 27, 2008 at 1:59 PM, Joe Walker <joe@...> wrote:

>
> Hi,
>
> I've just done a development build of DWR that includes an implementation of
> a Dojo Data Store that uses DWR.
> If you want a quick go, download the demo WAR file from here:
> - https://dwr.dev.java.net/servlets/ProjectDocumentList?folderID=9448
>
> Drop this into tomcat/jetty/etc and browse to:
> - http://localhost:8080/dwr/widgets/dojo-demo.html
>
> This shows of a set of 100,000 people in a table which supports sorting and
> paging.
>
> What do you need?
>
> <script type="text/javascript" src="DwrStore.js"> </script>
> <script>
> dojo.require(blahblah);
> function init() {
>   var store = new DwrStore("testServerData");
>   var model = new dojox.grid.data.DojoData();
>   model.store = store;
>   var grid = dijit.byId("grid");
>   grid.setStructure(blahblah);
>   grid.setModel(model);
>   grid.refresh();
> }
> dojo.addOnLoad(init);
> </script>
> <!-- other imports -->
> <div id="grid" dojoType="dojox.Grid" autoWidth="true"></div>
>
> And then on the server:
>
> MapStoreProvider<Person> provider = new
> MapStoreProvider<Person>(Person.class);
> Map<String, Person> crowd = provider.asMap();
> for (int i = 0; i < 100000; i++) {
>     crowd.put(getNextId(), getRandomPerson());
> }
> Directory.register("testServerData", provider);
>
> I started with 10 million people but that OOMed the JVM, so I backed off to
> 1million, which made dojo/firefox die. We appear to be good with 100000.
>
> There are a number of parts to this. A server-side Directory that holds a
> set of StoreProviders. In the example above, the client and the server use
> the directory to co-ordinate the use of a data store called
> "testServerData". The StoreProvider interface can be implemented a number of
> ways. We provide a MapStoreProvider and I've got a prototype
> SqlStoreProvider that demonstrates that this could work on top of a database
> rather than a Map.
> The client side of DWR then provides a interface that can used potentially
> by things other than a Dojo data store (see then end of engine.js). There is
> also a DwrStore.js that calls this API and implements
> Read/Identity/Notification. I'll be shaking the bugs out of Notification and
> finishing Write soon.
>
> Feedback welcome - particularly, there are a number of TODO items in
> DwrStore.js, many of which are questions that I need to get sorted
>
> Joe.
>
>
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://dojotoolkit.org/docs/book
> Forums: http://dojotoolkit.org/forum
> Dojo-interest@...
> http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...