2 Replies Latest reply on May 29, 2008 11:23 AM by beve

    Access field of an Object in a Controller variable

    beve

      Hi,

      I'm trying to access a field (firstName) of an Object instance (entireCustomerAsObject) like this:

      <task-node name="Review Order" async="true">
       <task name="Order Review">
       <assignment actor-id="user"/>
       <controller>
       <variable name="entireCustomerAsObject.firstName" access="read,write,required" mapped-name="customer_firstName"/>
       </controller>
       </task>
       <transition name="" to="Calculate Discount"/>
      </task-node>
      

      An object named 'entireCustomerAsObject' exists and is populated (if I remove the '.firstName' the object toString method is invoked and displayed in the form).
      Is it possbile to access a field of an object in the name attribute field like shown above? I've tried different combinations but without success.

      Thanks,

      /Daniel

        • 1. Re: Access field of an Object in a Controller variable
          kukeltje

           

          Is it possbile to access a field of an object in the name attribute field like shown above?


          No, the variable 'name' attribute is a string 'id' and not an object. The way you do it, you should have persisted a variable with the name "entireCustomerAsObject.firstName"

          • 2. Re: Access field of an Object in a Controller variable
            beve

            Ah, ok thanks!

            Just thinking about this...would it be possible to use an expression language like MVEL to support thes kind of access that I was on about?

            Something similar to this (ContextInstance):

            public Object getVariable(String name, Token token) {
             Object variable = null;
             TokenVariableMap tokenVariableMap = getTokenVariableMap(token);
             if (tokenVariableMap != null) {
             try {
             variable = MVEL.eval( name, tokenVariableMap.getVariablesLocally());
             }
             catch( Exception e )
             {
             variable = tokenVariableMap.getVariable(name);
             }
             }
             return variable;
             }
            


            Regards,

            /Daniel