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. #171
    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 lxbzmy View Post
    can not call a directmethod when a string param contains \n \r etc?
    why?
    The problems lies with the ExtDirect infrastructure, which is the one in charge of generating the JSON-encoded requests: ExtJs is not escaping the strings it sends to JSON, and therefore when the JSON encoded request reaches GSON, it just rejects strings having unescaped '\n' or '\r' characters -I think that is the right behaviour, according to what the JSON spec says with regard to strings.

    As a workaround, you can escape strings before you send them. Passing

    Code:
    'a\\\\nb\\\\r\c'
    in javascript to a direct method that just returns the received string will end up in

    Code:
    'a\nb\rc'
    being returned to Javascript, as proved by the following test:

    Javascript:
    Code:
      
      test_serverCallWithNewLineCharacters : function() {
        ServerMethodParametersReceptionTest.test_serverCallWithNewLineCharacters( 
               'a\\\\nb\\\\r\c',
          function(provider, response) {
            Djn.Test.checkSuccessfulResponse( "test_serverCallWithNewLineCharacters", 
                response, response.result === 'a\nb\rc', response.result);
          }
        );
      },
    Java code:
    Code:
      @DirectMethod
      public String test_serverCallWithNewLineCharacters( String arg ) {
        if( !arg.contains("\n") || !arg.contains( "\r"))
          throw new DirectTestFailedException( 
            "We expected that method to have have the \\n and \\r characters");
        
        return arg;
      }
    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/

  2. #172
    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 maho2nd View Post
    Thanks for your response!

    I read the post #155 but i thought Scope.Applications would save the private variables for the whole runtime and not only for a batch request. Because I need it only for the batch request.

    I tested the Scope.Applications Annotation by modify your demo , but it didn't worked:

    PHP Code:
    @ActionScope(scope=Scope.APPLICATION)
    public class 
    DirectStoreDemo {
        private 
    int count 0;
       
       [..] 
       
      @
    DirectMethod
      
    public synchronized void addCounter() {
          
        
    this.count++;

      }
      
      @
    DirectMethod
      
    public synchronized List<Experiencedjn_loadExperienceData() {
          
          
    this.count++;
        
        List<
    Experienceitems = new ArrayList<Experience>();
        
    Collections.addAllitems,
          new 
    ExperienceString.valueOf(count), """Programming, design and analysis in many projects, using Java, C#, C++, Smalltalk, Delphi, C"),[...]
        );
        return 
    items;
      } 
    web.xml:
    PHP Code:
    <init-param>
          <
    param-name>batchRequestsMultithreadingEnabled</param-name>
          <
    param-value>false</param-value
        </
    init-param
    In my script I call addCounter() multiple times an then I load a Grid with the data of
    loadExperienceData. But String.valueOf(count) is always 1. Firebug shows that all calls are send in 1 request.

    Can you help me?
    Ooops, I *completely* missed your 'Scope.BATCH' thing, so I answered assuming you were using one of the supported scopes.

    I do not plan on supporting that kind of scope, and to be fair I'm not sure it makes sense to add such a thing as a general purpose construction.

    With regard to your modification to the test application, it works perfectly well for me: the counter is correctly incremented every time I reload the page. And other users are using the Scope.APPLICATION happily.

    Hmm. Maybe you are inadvertently mixing the 1.2 alpha clasess with the 1.1 classes in the test app?

    That would explain that you can use the annotation (because it is found by your web server) but it does not have effect (maybe because the app is loading the old versions of the DJN classes).
    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/

  3. #173
    Ext User
    Join Date
    Nov 2009
    Posts
    16
    Vote Rating
    0
    maho2nd is on a distinguished road

      0  

    Default


    Quote Originally Posted by pagullo View Post
    Hmm. Maybe you are inadvertently mixing the 1.2 alpha clasess with the 1.1 classes in the test app?
    Thanks, that was the problem!

    Quote Originally Posted by pagullo View Post
    I do not plan on supporting that kind of scope, and to be fair I'm not sure it makes sense to add such a thing as a general purpose construction.
    It could be helpful, if you have some dependent requests which should be send as one request to the server. Then if one of the for example 3 requests fails, you can rollback the database transaction. But maybe there is better solution without using a Scope.Batch.

  4. #174
    Ext User
    Join Date
    Sep 2009
    Posts
    55
    Vote Rating
    0
    GregT is on a distinguished road

      0  

    Default


    Hi Pedro,

    Back on 11-27-2009 I posted a message on this thread regarding OOM errors, YUI compressor and DJN. Just wanted to let you know that I am now fairly convinced that this is a flaw in Tomcat. Basically, from testing and Googling, it seems you cannot reliably reload classes in Tomcat without eventually encountering OOM. The solution is either to restart it every time, or, perhaps, use JRebel. In any case, I don't think DJN is implicated.

    On another topic, off the top of your head, can I use something like request.getSession() via DJN? Eg. I want to know the session ID related to the request that DJN just handed me. I have not looked into this at all, just thought I'd throw it out there, it's probably a RTFM.

    Thanks again and as always, Happy Holidays.
    Greg

  5. #175
    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 GregT View Post
    Hi Pedro,

    Back on 11-27-2009 I posted a message on this thread regarding OOM errors, YUI compressor and DJN. Just wanted to let you know that I am now fairly convinced that this is a flaw in Tomcat. Basically, from testing and Googling, it seems you cannot reliably reload classes in Tomcat without eventually encountering OOM. The solution is either to restart it every time, or, perhaps, use JRebel. In any case, I don't think DJN is implicated.

    On another topic, off the top of your head, can I use something like request.getSession() via DJN? Eg. I want to know the session ID related to the request that DJN just handed me. I have not looked into this at all, just thought I'd throw it out there, it's probably a RTFM.

    Thanks again and as always, Happy Holidays.
    Greg
    Thanks, Greg, I will close the issue.

    And, yes, you can access the request, session, etc. by using the WebContext and WebContextManager classes. This is a new feature in the latest 1.2 alpha.

    See posting #155 for details.

    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/

  6. #176
    Ext User
    Join Date
    Mar 2009
    Posts
    71
    Vote Rating
    0
    J@y is on a distinguished road

      0  

    Default


    Hi Pedro,

    Is there any version of DJN which does not include Spring support?

    PS: stupid me, ignore my question please lol
    1.2 alpha should be the thing that I'm looking for.

  7. #177
    Ext User
    Join Date
    Nov 2009
    Posts
    15
    Vote Rating
    0
    jcalfee is on a distinguished road

      0  

    Default Cross site DirectJNgine calls

    Cross site DirectJNgine calls


    Please post an example of calling a method on a remote host. There is some sort of Direct iframe proxy that should allows this to work with DirectJNgine. This could lay the groundwork for a very useful JSON web services network.

  8. #178
    Sencha User
    Join Date
    Aug 2008
    Posts
    11
    Vote Rating
    0
    lxbzmy is on a distinguished road

      0  

    Default


    Quote Originally Posted by pagullo View Post
    The problems lies with the ExtDirect infrastructure, which is the one in charge of generating the JSON-encoded requests: ExtJs is not escaping the strings it sends to JSON, and therefore when the JSON encoded request reaches GSON, it just rejects strings having unescaped '\n' or '\r' characters -I think that is the right behaviour, according to what the JSON spec says with regard to strings.

    As a workaround, you can escape strings before you send them. Passing

    Code:
    'a\\\\nb\\\\r\c'
    in javascript to a direct method that just returns the received string will end up in

    Code:
    'a\nb\rc'
    being returned to Javascript, as proved by the following test:

    Javascript:
    Code:
      
      test_serverCallWithNewLineCharacters : function() {
        ServerMethodParametersReceptionTest.test_serverCallWithNewLineCharacters( 
               'a\\\\nb\\\\r\c',
          function(provider, response) {
            Djn.Test.checkSuccessfulResponse( "test_serverCallWithNewLineCharacters", 
                response, response.result === 'a\nb\rc', response.result);
          }
        );
      },
    Java code:
    Code:
      @DirectMethod
      public String test_serverCallWithNewLineCharacters( String arg ) {
        if( !arg.contains("\n") || !arg.contains( "\r"))
          throw new DirectTestFailedException( 
            "We expected that method to have have the \\n and \\r characters");
        
        return arg;
      }
    Extdirect php example execute successfull! when have \n in string .
    but djn failure. because djn decode hole json first and not encode them then.
    Code:
    JsonRequestProcessor.java
    
     private Object[] jsonStringToMethodParameters(RegisteredMethod method, String jsonParametersString, Class<?>[] parameterTypes, boolean debug) {
    ...   
       JsonElement[] jsonParameters = getJsonElements(jsonParametersString);
        Object[] result = getMethodParameters(parameterTypes, jsonParameters);
    //json decoded if \n in string \n become a new line
    ...
    Code:
     private Object[] getMethodParameters(Class<?>[] parameterTypes, JsonElement[] jsonParameters) {
        
          JsonElement jsonValue = jsonParameters[i];  
          String json = jsonValue.toString();
    //^ you simple use tostring method but jsonValue.toString() can not escape \n  in string 
    // jsonValue.toStirng()'s  result is  not a //valid json format
    // here must re encode to json format or add a Method toJSONString() i gson
     Object value = getGson().fromJson(json, parameterTypes[i]);
       //exception thrown here

  9. #179
    Ext User
    Join Date
    Sep 2009
    Posts
    55
    Vote Rating
    0
    GregT is on a distinguished road

      0  

    Default


    Hi Pedro and Happy New Year,

    I came across this problem. I have a method being called via DJN that includes an incoming type that is a custom subclass of the standard ArrayList (eg. 'class MyList extends ArrayList'). Everything compiles correctly but when I run it and call that method, I get this message:

    IllegalArgumentException: Can not set MyList field myList to java.util.LinkedList

    This happens while making the method call and it never gets to the first line of code inside the method. Upon poking around in your source and reading documentation, I think the core limitation is in GSON. Per the GSON documentation:

    Collections Limitations

    • Can serialize collection of arbitrary objects but can not deserialize from it
      • Because there is no way for the user to indicate the type of the resulting object
    • While deserializing, Collection must be of a specific generic type
    All of this makes sense, and is rarely a problem when following good Java coding practices


    I do not understand why what I am doing is considered by GSON to be a bad coding practice, but never mind that. More importantly, I'm not sure why GSON can't discover the correct subclass using Reflection or whatever it is that they do, same as any other type. Actually I'm not certain that I understand this problem correctly at all. Maybe it has something to do with generic type erasure.

    Wondering if you had any thoughts on this?

  10. #180
    Ext User
    Join Date
    Sep 2009
    Posts
    55
    Vote Rating
    0
    GregT is on a distinguished road

      0  

    Default


    Also Pedro I wonder if you could just confirm that I understand the basics of DJN marshalling correctly. Suppose in Java I have this:

    Class DjnTest {
    public void DoThis(String myThing) {}
    }

    In JS, I believe this is what happens under various scenarios (slightly simplified code for clarify, I am sure you see the point I am getting at):

    1. x = {myThing : 'foo'}; DjnTest.DoThis(x). Result in Java: myThing is equal to 'foo'. This would be the normal operation.

    2. x = {yourThing : 'foo'}; DjnTest.DoThis(x). Result in Java: myThing is equal to 'null', and the value I gave 'yourThing' is silently discarded.

    3. x = {myThing : 'foo'}; y = 'test', DjnTest.DoThis(x,y). Result: normal JS calling semantics cause DoThis to be called and the value of 'y' to be ignored. In Java, this looks the same as example #1.

    4. DjnTest.DoThis(). Result: normal JS calling semantics cause DoThis to be called and the value of 'myThing' in Java to be set to 'null'. In Java, this looks the same as #2.

    I believe that in all of these examples, no JS or Java-side error messages would appear anywhere. (I am not saying this is wrong or anything like that, I'm just trying to understand it. I think this is all rather basic, I just want to make sure I have it right?)

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)

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar