1. #11

    Default Full example up

    Full example up


    I've coded up a much more complete example.
    It demonstrates using ExtJS with jabsorb and an Apache Derby embedded database.

    Demo is up here:

    http://jabsorb.org/jabsorb-trunk/projectmetrics.html

    You can build and run the full demo by checking out the jabsorb SVN trunk:

    You will need JDK 1.5 or greater, and ant 1.65 or greater.


    svn checkout http://svn.jabsorb.org/svn/jabsorb/trunk jabsorb
    cd jabsorb
    ant test.dist run


    (this will run it directly with an embedded web server inside of ant)

    then connect to
    http://localhost:8084/projectmetrics.html

    Let me know if you have any questions.
    Last edited by Arthur.Blake; 21 Apr 2008 at 5:46 PM. Reason: update URL

  2. #12
    Ext User
    Join Date
    Apr 2008
    Posts
    8
    Vote Rating
    0
    Czy is on a distinguished road

      0  

    Default


    Thanks a lot, Arthur.

    I will inspect it and analyze inmediately.

    Czy.

  3. #13
    Ext User
    Join Date
    Apr 2008
    Posts
    8
    Vote Rating
    0
    Czy is on a distinguished road

      0  

    Default


    I have coded a Java class named "Formularios"


    Code:
    public class Formularios implements Serializable {
        public String[][] getTodasFamilias(){
            String[][] familias = ..... ;    // Content asignament to String[][]
            return familias ;
    }
    In JSP page, I register this class:

    Code:
    <jsp:useBean id="DatosParaFormulario" scope="page" class="czy.flora.jabsorb.Formularios" /> 
    <% JSONRPCBridge.registerObject( "datosForm", DatosParaFormulario );    %>
    Until now, I make a call to getTodasFamilias method, from this way:

    Code:
    var jsonrpc = new JSONRpcClient("JSON-RPC");
    var datosFamilias = jsonrpc.datosForm.getTodasFamilias();
    and this work fine. But now, I write a proxy, as you example:

    Code:
    var proxy = new Ext.data.JsonRpcProxy( jsonrpc.datosForm.getTodasFamilias );
    proxy.on( "loadexception", function(p,o,e){ excepcion(p,o,e); });
    And as result, it throw an exception: code 591. method not found (session may have timed out)

    What is I do wrong?

    Thanks you for you help, Arthur.

  4. #14

    Default


    Try changing the getTodasFamilias method to take one argument, a JSONObject (even if you don't use the argument.)

    Code:
     
    public class Formularios implements Serializable {
      public String[][] getTodasFamilias(JSONObject query){
        String[][] familias = ..... ;    // Content asignament to String[][]
        return familias ;
    }
    Because the proxy normally sends you a paging/query information Object (even if you aren't using it) you may need to do this...

  5. #15
    Ext User
    Join Date
    Apr 2008
    Posts
    8
    Vote Rating
    0
    Czy is on a distinguished road

      0  

    Default


    Eureka !! Now, it works fine.

    Thanks you very much, Arthur. Now I have two wonderfull tools for write web applications: Ext + Jabsorb.

  6. #16
    Ext User
    Join Date
    Apr 2008
    Posts
    8
    Vote Rating
    0
    Czy is on a distinguished road

      0  

    Default


    Quote Originally Posted by Arthur.Blake View Post
    Try changing the getTodasFamilias method to take one argument, a JSONObject (even if you don't use the argument.)

    Code:
     
    public class Formularios implements Serializable {
      public String[][] getTodasFamilias(JSONObject query){
        String[][] familias = ..... ;    // Content asignament to String[][]
        return familias ;
    }
    Because the proxy normally sends you a paging/query information Object (even if you aren't using it) you may need to do this...
    ... and how I do (from javascript side) if I want to pass any argument to the Java class? This arguments go into JSONObject or separately?

    And (in Java side) how can read those argument?

    Thanks again, Arthur.

  7. #17

    Default


    The way JsonRpcProxy works currently is to just pass a single JSONObject (or any other bean class you define.)

    If you examine:

    http://svn.jabsorb.org/websvn/jabsor...ile&rev=0&sc=0

    You can see pretty clearly how this works (it is passed as the params argument in the load method.)

    One really simple way to override this would be to write your own function in front of the json-rpc call and manipulate the data before you call it, like this:

    for example:

    Code:
     
    proxy = new Ext.data.JsonRpcProxy(function(callback, query){jsonrpc.Method.doStuff(callback, query, otherArg1, otherArg2,...);});
    With a little JavaScript magic, you could do anything you want.

  8. #18
    Ext User
    Join Date
    Apr 2008
    Posts
    8
    Vote Rating
    0
    Czy is on a distinguished road

      0  

    Default


    I'm sorry, Arthur, but I do not understand to you. It must be by my badly English.

    Let's work in a practical example. Until now, I coded proxy from this way :

    Code:
    var proxy = new Ext.data.JsonRpcProxy( jsonrpc.datosForm.getGeneros );
    In Java side, I coded this method thus:

    Code:
    public String[][] getGenerosDeLaFamilia( JSONObject query ) {....}
    and it work fine, but now, I want to modify the getGeneros method, with one argument.
    It must be thus:

    Code:
    public String[][] getGenerosDeLaFamilia( JSONObject query, String arg ) {....}
    That I must replace in javascript side? The code you have write:

    Code:
    proxy = new Ext.data.JsonRpcProxy(function(callback, query){jsonrpc.Method.doStuff(callback, query, otherArg1, otherArg2,...);});
    where have I to place ?

    Sorry by the inconvenience, and thanks one more time.

  9. #19

    Default


    No hay problema...

    In terms of your specific example, change:

    Code:
    var proxy = new Ext.data.JsonRpcProxy( jsonrpc.datosForm.getGeneros );
    to

    Code:
    var arg = ... ; 
    
    var proxy = new Ext.data.JsonRpcProxy( 
      function (cb, query) { 
        jsonrpc.datosForm.getGeneros (cb, query, arg);
      }
    );
    All we are doing is creating an anonymous function that does the actual JSON-RPC call and the proxy calls that anonymous function instead of the actual JSON-RPC call.

    Therefore you can pass any arguments you want to the getGeneros method--

    You could even omit the query argument entirely in this case and redefine your Java side method to not have the query argument since you don't use it...

    Like this:

    Code:
    var arg = ... ; 
    
     var proxy = new Ext.data.JsonRpcProxy( 
      function (cb, query) { 
        jsonrpc.datosForm.getGeneros (cb, arg);
      }
    );

  10. #20
    Ext User
    Join Date
    Apr 2008
    Posts
    8
    Vote Rating
    0
    Czy is on a distinguished road

      0  

    Default


    Good. Now, I understand all.

    Thanks a lot, Arthur.

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."