Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: [3.0] Ext.Direct with Java Servlet

  1. #1
    Sencha User
    Join Date
    Jul 2007
    Posts
    25
    Vote Rating
    0
      0  

    Lightbulb [3.0] Ext.Direct with Java Servlet

    Hello,

    ExtDirect4j is a LGPL Java library to implement Ext.Direct for Java Servlet.

    Here is the project url : http://code.google.com/p/extdirect4java

    Current release : 0.3.2

    Help, comments and suggestions are welcome !

    This is a small sample :

    Code:
    import ch.swissdotnet.extdirect4j.*;
    public class MyExtDirectRouter extends ExtDirectRouter  {
       @ExtRemoteAction(name = "Action", lazyInit = true)
       static public class TestAction {
           @ExtRemoteMethod
           public Result multy(long a) {
              return new Result(a * 2, "just a result");
           }
       }
       @Override
       protected void configureActions() {
          this.addAction(new AnnotatedAction(TestAction.class));
       }
    }
    a HTTP Get on the servlet will produce :
    Code:
    Ext.app.REMOTING_API = {"url":"http://localhost:8080/ExtDirectDemo/MyExtDirectRouter","type":"remoting","actions":{"Action":[{"name":"multy","len":1}]}};
    and a HTTP Post like
    Code:
    {"action":"Action","method":"multy","data":["3"],"type":"rpc","tid":2}
    will answer with :

    Code:
    {"result":{"result":6,"msg":"just a result"},"action":"Action","method":"multy","type":"rpc","tid":2}
    Best Regards

    Piziwate
    Last edited by piziwate; 13 Oct 2009 at 11:58 PM. Reason: updated sample

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Redwood City
    Posts
    30,626
    Vote Rating
    56
      0  

    Default

    How about a JSP tag which can output the

    Code:
    Ext.app.REMOTING_API = {"url":"/router","type":"remoting","actions":{"TestAction":[{"name":"multiply","len":1,"formHandler":false}]}};
    into your page?


    like:

    Code:
    <extdirect:api ns="Ext.app" class="TestAction,OtherClass,YetAnotherClass..."/>
    or

    Code:
    <extdirect:api ns="Ext.app" jar="MyRemoteMethodsJar.jar"/>
    And it analyses the class TestAction (and any others specified or found) using reflection, and class annotations:

    Code:
    public class TestAction{
        public TestAction() {
        }
    
        @ExtRemoteMethod
        public int multiply(int n) {
            return n * 4;
        }
    
    //  This doesn't get exported
        public void otherMethod {
        }
    }
    Longtime Sencha geek. Outspoken advocate of pure Javascript Views. Posts my own opinions.

  3. #3
    Ext JS Premium Member christocracy's Avatar
    Join Date
    Oct 2006
    Location
    Montreal
    Posts
    381
    Vote Rating
    0
      0  

    Default

    import ch.swissdotnet.extdirect4j.*;
    @piziwate You're from Switzerland, I assume? I happen to be in Zurich for the next week. I've worked with Ext.Direct a fair bit myself. Send me a PM with your email.
    /**
    * @author Chris Scott
    * @business www.transistorsoft.com
    * @rate $150USD / hr; training $500USD / day / developer (5 dev min)
    *
    * @SenchaDevs http://senchadevs.com/developers/transistor-software
    * @twitter http://twitter.com/#!/christocracy
    * @github https://github.com/christocracy
    */

  4. #4
    Ext User
    Join Date
    Jul 2007
    Posts
    13
    Vote Rating
    0
      0  

    Default

    wheres the doc

    how to run it in tomcat?
    taixiang shi
    ealpha@gmail.com

  5. #5
    Sencha User chalu's Avatar
    Join Date
    Feb 2008
    Location
    Benin City, Nigeria
    Posts
    480
    Vote Rating
    1
      0  

    Question

    Sorry if I sound late on this but first of all, I am just beginning to get my feet wet with DWR and now we've got Ext.Driect, assuming all I care about is Java on the server side, with DWR do I still need Ext.Direct ??

    Ext.Direct is great news all the same

  6. #6
    Ext User
    Join Date
    Feb 2008
    Posts
    16
    Vote Rating
    0
      0  

    Default

    any news about this library?!? The development seems to be stopped ...

  7. #7
    Ext JS Premium Member
    Join Date
    Feb 2009
    Posts
    11
    Vote Rating
    0
      0  

    Default any updates?

    I am eagerly seeking updates and a full working example of Ext.Direct for Java. Any updates? (I looked at the Google project for Ext.Direct for Java but it lacks the HTML/JS front-end to drive the example. As a newbie I am needing a complete example to help get up to speed.

    Thanks!

    -Steve

  8. #8
    Ext User
    Join Date
    Apr 2008
    Posts
    10
    Vote Rating
    0
      0  

    Default

    Hi all!
    Steve has added me in the project.
    I'm working on it at the moment.

    -Maxim-

  9. #9
    Ext User
    Join Date
    Apr 2008
    Posts
    10
    Vote Rating
    0
      0  

    Default Ext.Direct for Java update

    Hi, guys!
    I have just released a new 0.2 version of extdirect4j.
    It is available on project page http://code.google.com/p/extdirect4java/downloads/list
    This is simple example of how to use it:

    Code:
    public class MyExtDirectRouter  extends ExtDirectRouter {
    
        static public class Result {
            private Long result;
            private String msg;
    
            public Result(Long result, String msg) {
                this.result = result;
                this.msg = msg;
            }
        }
    
        static abstract public class AbstractAction {
            abstract Long multy(long a, long b);
    
            @ExtRemoteMethod(name = "multy1")
            public Long multy(int a, long b) {
                return -a * b;
            }
        }
    
        @ExtRemoteAction(name = "Action", lazyInit = true)
        static public class TestAction extends AbstractAction {
            @ExtRemoteMethod
            public Long multy(long a, long b) {
                return a * b;
            }
    
            @ExtRemoteMethod(name = "multy2")
            public Long multy(int a, long b) {
                return a * b;
            }
    
            @ExtRemoteMethod
            public Result multy(long a) {
                return new Result(a * 2, "just a result");
            }
        }
    
        @Override
        protected void configureActions() {
            this.addAction(new AnnotatedAction(TestAction.class));  //OK
            //or so..
            this.addAction(new AnnotatedAction("com.test.ExtdirectServlet$TestAction"));  //OK
            //or another else way in case we have not an access to action class in compile time
            //but it is less scaled and has some restrictions
            this.addAction(new NamedAction("com.test.ExtdirectServlet$TestAction")
                    .addMethod("multy", 1)   // OK
                    .addMethod("multy", 2)); //error there is 2 methods called "multy" with 2 arguments;
        }
    }
    Returned values and arguments can be any type.
    As json serialization/deserializatiois mechanism based on gson liblary you can also extend as it is specified in gson documentation: http://sites.google.com/site/gson/gson-user-guide
    Code:
    @Override
    protected void configureActions() {
       this.getGsonBuilder().registerTypeAdapter(MyType.class, new JsonSerializer(){...});
       ...
    }
    Sorry about it is not enough information. It will appear later more...
    Any questions/feature requests are wellcome!
    Here those that are already known:

    1.multiple transactions per request support(as it specified in Ext.Direct spec)
    2.form handling support

    Best Regards.
    Maxim

  10. #10
    Ext User
    Join Date
    Apr 2008
    Posts
    10
    Vote Rating
    0
      0  

    Default update 0.3 version

    New feature added:
    1.multiple transactions per request support

    http://code.google.com/p/extdirect4java/downloads/list

    web.xml snippet:
    Code:
        <servlet>
            <servlet-name>MyExtDirectRouter</servlet-name>
            <servlet-class>ch.swissdotnet.extdirect4j.MyExtDirectRouter </servlet-class>
            <init-param>
                <param-name>debug</param-name>
                <param-value>true</param-value>
            </init-param>
            <init-param>
                <param-name>remotingApiVar</param-name>
                <param-value>Ext.app.MY_REMOTING_API</param-value>
            </init-param>
            <init-param>
                <param-name>remoteUrl</param-name>
                <param-value>remote/</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>MyExtDirectRouter</servlet-name>
            <url-pattern>/remote/*</url-pattern>
        </servlet-mapping>

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •