Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    methodArguments - velocitycontext add own java methods

    Hi,

    I'm trying to use my own Java methods and Java objects via Velocity inside the operationBinding methodArguments, but no luck.

    I've got a method (tried with non-static and static version)
    Code:
     MyRPCUtil.getSecurityToken(DSRequest dsRequest)
    which returns object SecurityToken

    I'm trying:
    Code:
    securitytoken = MyRPCUtil(dsRsrequest);
    dsRequest.addToTemplateContext("MyUtil", new MyRPCUtil());
    dsRequest.addToTemplateContext("token", securitytoken);
    I do this just before dsRequest.setDataSource(myDS)
    and after that, I log what's in dsRequest.getTemplateContext():
    Code:
    Logger - MyUtil => com.p.rpc.MyRPCUtil@b3dfa6
    Logger - token => com.b.SecurityToken@1d6ca50
    DataSourceDMI - assigning: $token type: null
    DataSourceDMI - assigning: $dsRequest type: com.isomorphic.datasource.DSRequest
    ** I do notice that in the getTemplateContext, the pre-populated variables mentioned in the above API are not in the map. Shouldn't they be in there? Maybe I'm just adding these variables to the wrong context?
    Furthermore, I added $blablabla to the methodArguments, and this doesn't throw an exception.


    My custom operation is doSomething(SecurityToken st, DSRequest dsRequest) and I see the st is not replaced with my securitytoken, but it works for dsRequest.

    tried with these in my datasource XML:
    Code:
    methodArguments="$token,$dsRequest"
    methodArguments="$MyUtil.getSecurityToken($dsRequest),$dsRequest"



    Of course, I can just pass dsRequest to my custom operation and get the SecurityToken from there, but I'm hoping I don't need to pass the dsRequest to all my operations; unless this is recommended?
    If I remove the SecurityToken from my operation and leave out the methodArguments, all works perfectly automatically as stated in the API: "automatically pass a stock set of arguments to your method", which is very nice! :)



    SmartGWT EE SC_SNAPSHOT-2010-07-28/EVAL Deployment

    #2
    At the moment, the Velocity context for DMI method arguments doesn't include custom additions. Instead, you could fetch them manually from the DMI method itself.

    Comment


      #3
      Originally posted by Isomorphic
      At the moment, the Velocity context for DMI method arguments doesn't include custom additions. Instead, you could fetch them manually from the DMI method itself.
      Oh, then I'm confused because of this thread.

      Comment

      Working...
      X