View Poll Results: If you read it, did you find DirectJNgine User's Guide adequate?

Voters
54. You may not vote on this poll
  • Yes

    40 74.07%
  • No

    14 25.93%
  1. #191
    Ext User
    Join Date
    Nov 2009
    Posts
    15
    Vote Rating
    0
    jcalfee is on a distinguished road

      0  

    Default app engine compatability

    app engine compatability


    Great, I'm glad to hear the threads are optional. That makes this change minimal.

    I'm not using this at the moment, but I'll send you the patch once it is working in a project.

  2. #192
    Ext JS Premium Member minneyar's Avatar
    Join Date
    Apr 2009
    Location
    San Antonio, TX
    Posts
    35
    Vote Rating
    0
    minneyar is on a distinguished road

      0  

    Default


    Has anybody used the Ext.us.grid.GridFilters plugin in Ext 3.1 together with a DirectStore? I'm trying to do that, but I'm having some odd problems. I've got a DirectStore and a GridPanel using it that work fine with DirectJNgine, but when I add in a GridFilters plugin (with encode set to "true" and local set to "false"), it seems to have problems parsing the JSON sent as the filter argument. According to FireBug, the JSON posted to the servlet looks like this:

    Code:
    {"action":"RequestHandler","method":"getData","data":["signalUpTime","DESC",0,10,"[{\"type\":\"date\",\"comparison\":\"eq\",\"value\":\"01/12/2010\",\"field\":\"requestTime\"}]"],"type":"rpc","tid":1023}
    But when using DirectJNgine 1.0, I get exceptions in Tomcat's log that look like this:

    Code:
    Wed Jan 20 2010 20:14:30:282 - [ERROR] JsonRequestProcessor -rid: 1023- (Controlled) server error: Failed parsing JSON source: java.io.StringReader@5d282c43 to Json for Method 'RequestHandler.getData'                                                                                                        
    com.google.gson.JsonParseException: Failed parsing JSON source: java.io.StringReader@5d282c43 to Json
            at com.google.gson.JsonParser.parse(JsonParser.java:57)
            at com.google.gson.JsonParser.parse(JsonParser.java:39)
            at com.softwarementors.extjs.djn.router.processor.standard.json.JsonRequestProcessor.getIndividualRequestJsonParameters(JsonRequestProcessor.java:286)
            at com.softwarementors.extjs.djn.router.processor.standard.json.JsonRequestProcessor.checkJsonMethodParameterTypes(JsonRequestProcessor.java:306)
            at com.softwarementors.extjs.djn.router.processor.standard.json.JsonRequestProcessor.getIndividualRequestParameters(JsonRequestProcessor.java:223)
            at com.softwarementors.extjs.djn.router.processor.standard.json.JsonRequestProcessor.processIndividualRequest(JsonRequestProcessor.java:365)
            at com.softwarementors.extjs.djn.router.processor.standard.json.JsonRequestProcessor.processIndividualRequestsInThisThread(JsonRequestProcessor.java:127)
            at com.softwarementors.extjs.djn.router.processor.standard.json.JsonRequestProcessor.process(JsonRequestProcessor.java:109)
            at com.softwarementors.extjs.djn.router.RequestRouter.processJsonRequest(RequestRouter.java:77)
            at com.softwarementors.extjs.djn.servlet.DirectJNgineServlet.doPost(DirectJNgineServlet.java:377)
            at java.lang.Thread.run(Thread.java:619)                                                                                                                  
    Caused by: com.google.gson.ParseException: Encountered "type" at line 1, column 33.       Was expecting one of:                                                                                               "," ...
        "]" ...
            at com.google.gson.JsonParserJavacc.generateParseException(JsonParserJavacc.java:658)
            at com.google.gson.JsonParserJavacc.jj_consume_token(JsonParserJavacc.java:540)
            at com.google.gson.JsonParserJavacc.JsonArray(JsonParserJavacc.java:134)
            at com.google.gson.JsonParserJavacc.parse(JsonParserJavacc.java:22)
            at com.google.gson.JsonParser.parse(JsonParser.java:53)
            ... 33 more
    I'm guessing that somehow, the "]" on the end of the filters parameter is getting lost. My suspicion is reinforced when I test it against the current DirectJNgine 1.2 beta; it doesn't throw an exception, and the function gets called, by the string passed in to the "filters" argument looks like this when I print it out:

    Code:
    [{"type":"date","comparison":"eq","value":"01/12/2010","field":"requestTime"}
    Any idea what's going wrong? I can manually add a "]" to the end of the string and then parse it, but that's quite a kludge...

  3. #193
    Ext JS Premium Member
    Join Date
    May 2009
    Location
    Barcelona (Spain)
    Posts
    218
    Vote Rating
    19
    pagullo will become famous soon enough pagullo will become famous soon enough

      0  

    Default


    Quote Originally Posted by jcalfee View Post
    Great, I'm glad to hear the threads are optional. That makes this change minimal.

    I'm not using this at the moment, but I'll send you the patch once it is working in a project.
    Great!

    Right now I'm making DJN 1.2 beta 1 available: you will probably want to use this beta as the starting point to add this functionality.

    You can download it from http://code.google.com/p/directjngine/

    Best regards,
    Pedro Agulló, Barcelona (Spain)
    Agile team building, consulting, training & development
    DirectJNgine: http://code.google.com/p/directjngine - Log4js-ext: http://www.softwarementors.com/projects/p/log4js-ext/

  4. #194
    Ext JS Premium Member
    Join Date
    May 2009
    Location
    Barcelona (Spain)
    Posts
    218
    Vote Rating
    19
    pagullo will become famous soon enough pagullo will become famous soon enough

      0  

    Default DJN 1.2 beta 1 released

    DJN 1.2 beta 1 released


    Today I am releasing DJN 1.2 beta 1. You can download it from http://code.google.com/p/directjngine/.

    Here is a list of what's new and improved.

    For detailed info, check the User's Guide, which has been updated and has new chapters devoted to the new functionality.


    New in DJN 1.2: Support for stateful actions
    It is possible to have session and application scoped actions, that will remember their state between requests.

    To make an action stateful, use the @ActionScope annotation.

    Take a look at the new chapter in the User's Guide to get more information about stateful actions.

    Sample code:

    Code:
    @ActionScope(scope=Scope.SESSION)
    public class SessionStatefulActionTest {
      int count;
      String value;
      // ...
    }
    Once the SessionStatefulActionTest action is declared to be session scoped, it will be stored in the user session: this means that its count and value fields will be remembered across request belonging to the same user session.


    New in DJN 1.2: Support for accessing the current session, etc. from within action methods
    Now it is possible to get access to the current session, servlet context, servlet configuration, etc., from within action methods.
    To do that, just use the new WebContext and WebContextManager classes.

    Take a look at the new chapter in the User's Guide to get more information about WebContext.

    Sample code:

    Code:
    @DirectMethod
    public WebContextInfo test_webContext() {
      WebContext context = WebContextManager.get();
      HttpSession session = context.getSession();
      ServletContext application = context.getServletContext();
        
      // Keep a counter of how many times we have called this method 
      // in this session
      Integer callsInSession=(Integer)session.getAttribute("callsInSession");
      if( callsInSession == null ) {
        callsInSession = new Integer(0);
      }
      callsInSession = new Integer(callsInSession.intValue() + 1);
      session.setAttribute("callsInSession", callsInSession);
    
      // ...
    }
    You will probably find that using session/application scoped actions might be an easier way to accomplish your goals, though.


    New in DJN 1.2: Support for multiple action instances
    Now that actions can be stateful, it makes sense to have more than one action instance for a given Java class, each instance manging its own state.

    Other additions/improvements

    · All bugs reported against DJN 1.1 have been fixed.

    · We have added more tests, mostly to ensure bug fixes work: we have 100 hundred automated tests nowadays.

    · We have moved to ExtJs 3.1 for testing to ensure that we remain up to date.

    · Licensing has been "fixed": we are LGPL v3 -the way it was intended to be from the beginning.


    Code breaking changes
    · The programmatic API has been modified so that poll methods belong to actions, instead of being global. This was a must to support stateful actions.

    · The suggested workaround for handling "\n" and "\r" characters in DJN 1.1 does not work anymore: instead you should pass them "as-is".


    Tested browsers
    · Internet Explorer 8: 8.0.6001.18702

    · Firefox 3.5.3

    · Safari 4.0 (530.17)

    · Google Chrome 3.0.195.53

    · Opera 9.64.


    Other issues
    · Testing: the automated 'test_getSessionData' test fails sometimes. This is due to difficult to fix test timing issues.
    If you execute the test method several times, the false error will probably not appear again.
    We intend to fix this for the final DJN release.

    · Integration with Ext JS Designer is planned, but this will depend on the ExtJS Designer release date.


    Intent of this release
    The first goal of this release is to expose the new support for state handling via stateful actions and WebContext. I consider that API to be closed -unless you find a big problem.

    The second goal is to get feedback on enhancements in DJN that will help people creating DJN extensions (Spring support by vlagorce comes to mind).

    I had to change several APIs to support cleaner extension: while I think moving existing extensions to 1.2 will be very easy, I wanted to provide this beta in order to get feedback and help to port extensions to 1.2 before the final release. My current plan is to release DJN 1.2 final in about two weeks: I hope this is time enough for you to check whether the internal API changes are ok with you.


    To all, thank you for your encouragement and criticism: I hope this new release of DJN helps you make bettter software.

    Best regards.
    Pedro Agulló, Barcelona (Spain)
    Agile team building, consulting, training & development
    DirectJNgine: http://code.google.com/p/directjngine - Log4js-ext: http://www.softwarementors.com/projects/p/log4js-ext/

  5. #195
    Ext JS Premium Member minneyar's Avatar
    Join Date
    Apr 2009
    Location
    San Antonio, TX
    Posts
    35
    Vote Rating
    0
    minneyar is on a distinguished road

      0  

    Default


    After further investigation, I discovered that the 1.2 beta was truncating the last character of all of my strings. I'm not sure if I'm the only person who's experienced the problem, but every single string I sent through Ext.Direct to a DirectJNgine servlet was missing the last character when I printed it out, even on calls that weren't trying to use the grid filtering at all.

    I decided to give version 1.1 a try, and I got the same exception as I did when using version 1.0. I tried turning debugging all the way up and adding in a few log statements of my own to DirectJNgine's code, and as far as I can tell, the issue is that Gson is having problems parsing a JSON string that contains an escaped JSON string inside it, not that DirectJNgine is doing anything wrong. :-(

    I've got a working solution, but I ended up modifying the code in the GridFilters plugin; the "normal" behavior is that if the "encode" flag is set to true, it will convert the object to a JSON string and add that to the parameters for the POST request, and if "encode" is false, it will flatten the object into a series of parameters and add them all to the request. I modified the code in my GridFilters plugin so that if "encode" is false, it will instead just copy the filters object into the parameters, which then gets turned into JSON with the rest of the object when the request is submitted. I then made a custom Gson parser to turn that object into a Java class. This seems to work fine.

  6. #196
    Ext JS Premium Member
    Join Date
    May 2009
    Location
    Barcelona (Spain)
    Posts
    218
    Vote Rating
    19
    pagullo will become famous soon enough pagullo will become famous soon enough

      0  

    Default


    Quote Originally Posted by minneyar View Post
    After further investigation, I discovered that the 1.2 beta was truncating the last character of all of my strings. I'm not sure if I'm the only person who's experienced the problem, but every single string I sent through Ext.Direct to a DirectJNgine servlet was missing the last character when I printed it out, even on calls that weren't trying to use the grid filtering at all.

    I decided to give version 1.1 a try, and I got the same exception as I did when using version 1.0. I tried turning debugging all the way up and adding in a few log statements of my own to DirectJNgine's code, and as far as I can tell, the issue is that Gson is having problems parsing a JSON string that contains an escaped JSON string inside it, not that DirectJNgine is doing anything wrong. :-(

    I've got a working solution, but I ended up modifying the code in the GridFilters plugin; the "normal" behavior is that if the "encode" flag is set to true, it will convert the object to a JSON string and add that to the parameters for the POST request, and if "encode" is false, it will flatten the object into a series of parameters and add them all to the request. I modified the code in my GridFilters plugin so that if "encode" is false, it will instead just copy the filters object into the parameters, which then gets turned into JSON with the rest of the object when the request is submitted. I then made a custom Gson parser to turn that object into a Java class. This seems to work fine.
    Truncating the last character in all strings? Really weird!

    If you provide me with a minimal project that systematically shows this behavior, I will take a look at it. You are talking about "escaped" JSON strings, can you provide me with a pair of strings highlighting the problem?

    Just in case, did you check the GSON forums/mailing lists/whatever they have? It might be some known issue.

    Thanks for reporting the issue
    Pedro Agulló, Barcelona (Spain)
    Agile team building, consulting, training & development
    DirectJNgine: http://code.google.com/p/directjngine - Log4js-ext: http://www.softwarementors.com/projects/p/log4js-ext/

  7. #197
    Ext JS Premium Member minneyar's Avatar
    Join Date
    Apr 2009
    Location
    San Antonio, TX
    Posts
    35
    Vote Rating
    0
    minneyar is on a distinguished road

      0  

    Default


    Quote Originally Posted by pagullo View Post
    If you provide me with a minimal project that systematically shows this behavior, I will take a look at it.
    Sure, I can do that. I don't really want to post a whole WAR file since including all the libraries will make it rather large, but I'll paste the pertinent source code here.

    The test class here just has a single DirectMethod function that accepts a String, logs it, and then returns that same String. testpage.html creates an Ext.Window that has two buttons; one sends the string "testing" to TestClass and then appends the return value to the window, and the second one creates an object, uses Ext to transform it into JSON, and sends that to TestClass.

    With DirectJNgine 1.1, the first button echoes back "testing", and the second button causes Tomcat to throw a JsonParseException. With 1.2.beta_1, the first button echoes back "testin", and the second button echoes back the expected JSON string, except it's missing a "}" on the end.

    For what it's worth, this is running on Tomcat 6.0.20 on a Red Hat Enterprise Linux 5.3 server. I don't think it would make a difference, but we have a number of other libraries in our Tomcat's lib dir, including Sun's thin JDBC driver, Log4j 1.2.15, Xerces, JacORB 2.3.1, SLF4J, and a few custom libs, as well as all of DirectJNgine's requirements.

    testpage.html:
    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    
            <link href="lib/ext/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
    
            <title>Test Page</title>
    
            <script language="JavaScript1.5" type="text/javascript" src="lib/prototype/prototype.js"></script>
            <script language="JavaScript1.5" type="text/javascript" src="lib/scriptaculous/scriptaculous.js"></script>
            <script language="JavaScript1.5" type="text/javascript" src="lib/ext/adapter/prototype/ext-prototype-adapter-debug.js"></script>
            <script language="JavaScript1.5" type="text/javascript" src="lib/ext/ext-all-debug.js"></script>
            <!-- This file is automatically generated by DirectJNgine, based on 
            config parameters in the web.xml file. -->
            <script language="JavaScript1.5" type="text/javascript" src="direct/Api.js"></script>
    
            <script language="JavaScript1.5" type="text/javascript">
            var win = null;
            Ext.Direct.addProvider(Ext.app.REMOTING_API);
            window.onload = function addTestButton() {
    
                /** Setting for Ext JS to locate black gif used by widgets */
                Ext.BLANK_IMAGE_URL = "lib/ext/resources/images/default/s.gif";
                Ext.SSL_SECURE_URL = "lib/ext/resources/images/default/s.gif";
    
                Ext.onReady(function() {
                    Ext.QuickTips.init();
                    var qt = Ext.QuickTips.getQuickTip();
                    qt.interceptTitles = true;
                });
    
                win = new Ext.Window({
                    title: 'Test Window',
                    items: [
                    {
                        xtype: 'button',
                        text: 'Truncation test',
                        handler: function() {
                            TestClass.doStuff( "testing", function(response) {
                                win.add(new Ext.Panel({html: response}));
                                win.doLayout();
                                win.syncShadow();
                            });
                        }
                    }, {
                        xtype: 'button',
                        text: 'Embedded JSON test',
                        handler: function() {
                            var thing = {
                                one: 'hello',
                                two: ['first', 'second', 'third'],
                                three: {
                                    anotherThing: 'four'
                                }
                            };
                            TestClass.doStuff( Ext.util.JSON.encode(thing), function(response) {
                                win.add(new Ext.Panel({html: response === undefined ? "undefined" : response}));
                                win.doLayout();
                                win.syncShadow();
                            });
                        }
                    }
                    
                    ]
                });
                win.show();
            };
            </script>
        </head>
        <body>
        </body>
    </html>
    org.test.TestClass.java:
    Code:
    package org.test;
    
    import org.apache.log4j.Logger;
    
    import com.softwarementors.extjs.djn.config.annotations.DirectMethod;
    
    public class TestClass
    {
        private static final Logger logger = Logger.getLogger( TestClass.class );
        @DirectMethod
        public static String doStuff(String testString) {
            logger.info( "Got:\n" + testString );
            
            return testString;
        }
    }
    web.xml:
    Code:
    <!DOCTYPE web-app PUBLIC
    '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN'
    'http://java.sun.com/dtd/web-app_2_3.dtd'>
    <web-app>
    
        <display-name>Test</display-name>
    
        <description>
            Just testing.
        </description>
    
        <servlet>
            <servlet-name>DjnServlet</servlet-name>
            <servlet-class>com.softwarementors.extjs.djn.servlet.DirectJNgineServlet</servlet-class>
            <init-param>
                <param-name>providersUrl</param-name>
                <param-value>djn/directprovider</param-value>
            </init-param>
            <init-param>
                <param-name>apis</param-name>
                <param-value>direct</param-value>
            </init-param>
            <init-param>
                <param-name>direct.apiFile</param-name>
                <param-value>direct/Api.js</param-value>
            </init-param>
            <init-param>
                <param-name>direct.apiNamespace</param-name>
                <param-value>Ext.app</param-value>
            </init-param>
            <init-param>
                <param-name>batchRequestsMultithreadingEnabled</param-name>
                <param-value>false</param-value>
            </init-param>
            <init-param>
                <param-name>direct.classes</param-name>
                <param-value>
                    org.test.TestClass
                </param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>DjnServlet</servlet-name>
            <url-pattern>/djn/directprovider/*</url-pattern>
        </servlet-mapping>
    
    </web-app>

  8. #198
    Sencha User
    Join Date
    Nov 2007
    Posts
    294
    Vote Rating
    0
    Sesshomurai is on a distinguished road

      0  

    Default I need paramsAsHash for DirectStore load

    I need paramsAsHash for DirectStore load


    Hi,
    I am converting to Direct using this nice package. I have some grid stores that use dynamic parameters to load the grid. So, for this, I need to use paramsAsHash=true, but for some reason DirectJNgine says it cannot use this setting with DirectStore calls.

    is this true? Why? And how can I do this otherwise?

    thank you for any tips!

  9. #199
    Sencha User
    Join Date
    Nov 2007
    Posts
    294
    Vote Rating
    0
    Sesshomurai is on a distinguished road

      0  

    Default


    There also appears to be a bug in 1.2 beta where if I try to send a basic string parameter that is long, the JSON conversion fails.

    Code:
    JsonException: Failed attempt to convert from a json string to java method parameters. Method='GridwaveList.getList', Json string='["symphony","jsonname='properties' and jsoncount='numProperties' and ablablablablablablabla"]', ExpectedTypes='java.lang.String, java.lang.String'
    If I shorten my second parameter a few characters, it works.

    EDIT: I traced this problem to the class JsonRequestProcessor.java around line 305.

    Code:
          if( isString(jsonValue) ) { // Just because of '\n' or '\r', which were decoded previously, so we need to re-encode them
            json = reEncode(jsonValue.toString());
          }
    The reEncode wasn't working well in many cases.

    Also, I found that DirectJNgine 1.2 beta does not work with Ext 3.1 release. It complains that all parameters are undefined. However, it worked fine with ExtJS 3.1.1-beta (which my app doesn't yet work with).

    Will DirectJNgine 1.2 release work with ExtJS 3.1 release?

    thanks

  10. #200
    Ext JS Premium Member
    Join Date
    May 2009
    Location
    Barcelona (Spain)
    Posts
    218
    Vote Rating
    19
    pagullo will become famous soon enough pagullo will become famous soon enough

      0  

    Default


    Quote Originally Posted by Sesshomurai View Post
    Hi,
    I am converting to Direct using this nice package. I have some grid stores that use dynamic parameters to load the grid. So, for this, I need to use paramsAsHash=true, but for some reason DirectJNgine says it cannot use this setting with DirectStore calls.

    is this true? Why? And how can I do this otherwise?

    thank you for any tips!
    Of course, you can do that: you just need to implement a JSON handling method whenever you don't know the parameter names in advance.

    Check the User's Guide, chapter "Handling JSON data directly".

    Regards,
    Pedro Agulló, Barcelona (Spain)
    Agile team building, consulting, training & development
    DirectJNgine: http://code.google.com/p/directjngine - Log4js-ext: http://www.softwarementors.com/projects/p/log4js-ext/

Thread Participants: 86

  1. Animal (5 Posts)
  2. barton (4 Posts)
  3. Condor (1 Post)
  4. mauro_monti (6 Posts)
  5. mbarto (1 Post)
  6. aconran (1 Post)
  7. MoShAn480 (1 Post)
  8. asgillett (2 Posts)
  9. seade (4 Posts)
  10. zaqwsxqwer (3 Posts)
  11. Sesshomurai (16 Posts)
  12. ThierryC (3 Posts)
  13. maxm165 (3 Posts)
  14. techstudios (2 Posts)
  15. sayonara (2 Posts)
  16. kschlaudt (1 Post)
  17. hschaefer123 (2 Posts)
  18. omarc (2 Posts)
  19. lxbzmy (4 Posts)
  20. mct (6 Posts)
  21. mediacept (2 Posts)
  22. dionisexorcius (1 Post)
  23. alper (1 Post)
  24. steverc (2 Posts)
  25. chrizmaster (18 Posts)
  26. J@y (21 Posts)
  27. Georgioa (6 Posts)
  28. wguan (1 Post)
  29. minneyar (16 Posts)
  30. jhoweaa (1 Post)
  31. Ramez (2 Posts)
  32. malus (1 Post)
  33. dweller (8 Posts)
  34. stdunbar (1 Post)
  35. vlagorce (20 Posts)
  36. cwilliso (1 Post)
  37. Whatty (13 Posts)
  38. Ice (1 Post)
  39. clynnh (1 Post)
  40. SreevaniN (1 Post)
  41. Stsalomon90 (1 Post)
  42. GregT (9 Posts)
  43. jcalfee (6 Posts)
  44. set_ti (1 Post)
  45. maho2nd (3 Posts)
  46. dreamtaotao (3 Posts)
  47. Toxa (4 Posts)
  48. tungchau (3 Posts)
  49. wlan0 (2 Posts)
  50. jpr (2 Posts)
  51. gianmarco (5 Posts)
  52. extjslikeit (2 Posts)
  53. harmen_wessels (1 Post)
  54. Olivercomputing2 (4 Posts)
  55. vanessa_ng (2 Posts)
  56. alois.cochard (5 Posts)
  57. kyrillos52 (2 Posts)
  58. Tod (1 Post)
  59. Alinanila (1 Post)
  60. tfannon (2 Posts)
  61. Kynao (1 Post)
  62. feiq (4 Posts)
  63. dalt (1 Post)
  64. xfolch (1 Post)
  65. avijit (1 Post)
  66. marcelsnews (2 Posts)
  67. maddhippy (1 Post)
  68. sritter (1 Post)
  69. july (2 Posts)
  70. jtkeller7983 (1 Post)
  71. lfranchini (2 Posts)
  72. 7/11 (2 Posts)
  73. yAdEs (1 Post)
  74. zazz (1 Post)
  75. waqar (5 Posts)
  76. pjain11 (1 Post)
  77. alexMobimesh (2 Posts)
  78. zachHurt (4 Posts)
  79. n0n3 (5 Posts)
  80. adavis2 (1 Post)
  81. mark.peters (1 Post)
  82. lee el (4 Posts)
  83. frengo19 (3 Posts)
  84. prakashwagle (1 Post)
  85. extejnar (2 Posts)
  86. alin@sonatype.com (1 Post)