Hybrid View

  1. #1
    Ext User
    Join Date
    Apr 2007
    Posts
    379
    Vote Rating
    0
    sfwalter is on a distinguished road

      0  

    Default Ext + Java + Spring + DWR

    Ext + Java + Spring + DWR


    Hi,

    I have created a little demo to show how to integrate Ext with Java/Spring/DWR. I took the DWR Proxy/Reader that has been posted in the forums and modified it a bit. For example I have a boolean flag that can be passed when you construct a DWR Proxy. This will allow you to indicate if you want to support paging and remote sorting. In case you do your service methods that you expose via spring/dwr will need three additional parameters. But if you don't want to support paging and remote sorting you can leave those parameters out.

    The DWR Reader also supports nested properties. For example if you are returning a customer object that has an address object within it.

    Here is the url java-ext.zip.

    The download is a about 3.5mb but includes everything you need: ext 1.0, dwr, spring, sample code. An ant build file is also included but you may need to modify the build.properties file for your environment.

    cheers,

    scott

  2. #2
    Ext User
    Join Date
    Apr 2007
    Posts
    6
    Vote Rating
    0
    lambert is on a distinguished road

      0  

    Default


    Here, I have a question。
    we can call a java object method and get a Javascript object with DWR.
    yui-ext only need use MemoryProxy to put the Javascript object in to the Component.
    Why do we need a DWRProxy? Improve performance? or in order to use some server characteristics like hibernate delay Loading?

  3. #3
    Ext User
    Join Date
    Apr 2007
    Posts
    379
    Vote Rating
    0
    sfwalter is on a distinguished road

      0  

    Default


    You would want to use the DWRProxy for seamless integration.

    1. You don't need to have a separate call back method to handle DWR's response if you use the DWRProxy its handled automatically for you.

    2. If you want to do paging and/or remote sorting you don't have to worry about making multiple calls on your own to the remote method on the server. As you page through a grid component, the DWRProxy will make the calls for you.

  4. #4
    Ext User
    Join Date
    Apr 2007
    Posts
    14
    Vote Rating
    0
    codegenic is on a distinguished road

      0  

    Default ListRange purpose?

    ListRange purpose?


    Thank you for posting this - I'm about to embark on using Ext with Spring and DWR so it should be quite helpful!

    Forgive my ignorance on this, I'm yet to even try using Ext in any meaningful way - especially Grids.

    Is there a specific reason for wrapping the returned data in the ListRange class? Is this just to get the total number of records to the Grid? Presuming there is no paging involved would returning a List from the DWR call and using the size() of the list achieve the same thing?

  5. #5
    Ext User
    Join Date
    Apr 2007
    Posts
    379
    Vote Rating
    0
    sfwalter is on a distinguished road

      0  

    Default


    Quote Originally Posted by codegenic View Post
    Thank you for posting this - I'm about to embark on using Ext with Spring and DWR so it should be quite helpful!

    Forgive my ignorance on this, I'm yet to even try using Ext in any meaningful way - especially Grids.

    Is there a specific reason for wrapping the returned data in the ListRange class? Is this just to get the total number of records to the Grid? Presuming there is no paging involved would returning a List from the DWR call and using the size() of the list achieve the same thing?
    Correct, the ListRange is really only need if you want to support paging. Feel free to have your method return an array or a java.util.List object.

  6. #6
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,496
    Vote Rating
    44
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Quote Originally Posted by codegenic View Post
    Is there a specific reason for wrapping the returned data in the ListRange class? Is this just to get the total number of records to the Grid?

    I'm thinking of adding to my ListRange class, things like return status level, (SUCCESS, WRANING and FATAL), and return message, so that errors which break the grid, and failures which don't break the grid, but cause individual operations not to work can be handled elegantly by the Grid.

  7. #7
    Ext User
    Join Date
    Mar 2007
    Posts
    16
    Vote Rating
    0
    cmd.ares is on a distinguished road

      0  

    Default


    about api Ext.onReady .
    the Ext.onReady(GridUI.init) is also running in the application
    I do not understand the difference of
    Ext.onReady(GridUI.init, GridUI, true);
    and
    Ext.onReady(GridUI.init);

    most demo of the yui is onReady(Function fn) and
    could you tell me how to use onReady(Function fn, Object scope, boolean override)?
    thanks.

  8. #8
    Ext User
    Join Date
    Apr 2007
    Posts
    6
    Vote Rating
    0
    lambert is on a distinguished road

      0  

    Thumbs up


    Ah, it was so. Thank for your answer and share the source.

  9. #9
    Banned
    Join Date
    Mar 2007
    Posts
    57
    Vote Rating
    0
    buzz is on a distinguished road

      0  

    Default


    Dropped the war under tomcat and I got an error. TodoService is not defined. Fixed it by replacing the absolute javascript paths /springapp/dwr/.... to relative paths dwr/TodoService.js in index.jsp.
    Now I don't get any error but no data is being displayed in the grid. All I see are the column hearders. Using firebug I see that the data is being sent back by the server.

  10. #10
    Ext User
    Join Date
    Apr 2007
    Posts
    379
    Vote Rating
    0
    sfwalter is on a distinguished road

      0  

    Default


    hmmm thats weird. Once you have the page loaded try this in the firebug console:

    Code:
    GridUI.getStore().getCount()
    it should return "5", if that works try this:

    Code:
    GridUI.getStore().getAt(0).data.description
    it should return "item1". Let me know your findings

    scott.