3 Replies Latest reply on Sep 18, 2008 9:27 AM by Vesta0424

    Objects:  Referencing Values

    Vesta0424
      Thanks in advance for anyone's help. This is something that I find most confusing in Flex, working with the various datatypes, casting, what can be cast as what, how to do it correctly, etc..

      The application on which I am working has a process where a user submits a request for leave (i.e., vacation) that is sent via a web service. The return, if the submit is successful, returns an Object that is essentially a copy of the original request. I have no control over the return result -- that is, it is not possible to specify e4x as my return format. I have to work with the object. This should be easy(?), but .....

      I need to access a subset of the return object -- the detail (2 objects in this instance) -- and bind it to a DataGrid. Below is a trace of the result object using ObjectUtil.toString(obj). How do I work with this data to get at what I need?

      Thanks again.

      Georgia

      TRACE:



      confirmOBJ to String:
      (Object)#0
      comment = (null)
      details = (Object)#1
      detail = (mx.collections::ArrayCollection)#2
      filterFunction = (null)
      length = 2
      list = (mx.collections::ArrayList)#3
      length = 2
      source = (Array)#4
      [0] (Object)#5
      absense_days = (Object)#6
      xsi:nil = 1
      absense_hours = 7.5
      attendance_type_id = 22
      date_end = "2008-09-16T20:00:00.000-04:00"
      date_start = "2008-09-16T20:00:00.000-04:00"
      detail_id = 10945
      time_end = "16:45"
      time_start = "08:15"
      [1] (Object)#7
      absense_days = (Object)#8
      xsi:nil = 1
      absense_hours = 7.5
      attendance_type_id = 22
      date_end = "2008-09-17T20:00:00.000-04:00"
      date_start = "2008-09-17T20:00:00.000-04:00"
      detail_id = 10946
      time_end = "16:45"
      time_start = "08:15"
      uid = "932A2D2B-98CC-74B0-6418-7551B4710447"
      sort = (null)
      source = (Array)#4
      parent = (Object)#9
      committed_flag = "N"
      creator_id = 1777
      lookup_code = "PENDING"
      open_flag = "Y"
      parent_id = 148
      person_id = 20141




      Text
        • 1. Re: Objects:  Referencing Values
          Peter Lorent Level 2
          What happens if you trace
          result[0].absense_days.absense_hours
          • 2. Re: Objects:  Referencing Values
            Level 7

            "Vesta0424" <webforumsuser@macromedia.com> wrote in message
            news:gatgh7$qcn$1@forums.macromedia.com...
            > Thanks in advance for anyone's help. This is something that I find most
            > confusing in Flex, working with the various datatypes, casting, what can
            > be
            > cast as what, how to do it correctly, etc..
            >
            > The application on which I am working has a process where a user submits a
            > request for leave (i.e., vacation) that is sent via a web service. The
            > return,
            > if the submit is successful, returns an Object that is essentially a copy
            > of
            > the original request. I have no control over the return result -- that
            > is, it
            > is not possible to specify e4x as my return format. I have to work with
            > the
            > object. This should be easy(?), but .....

            Why is that not possible?

            > I need to access a subset of the return object -- the detail (2 objects in
            > this instance) -- and bind it to a DataGrid. Below is a trace of the
            > result
            > object using ObjectUtil.toString(obj). How do I work with this data to
            > get
            > at what I need?

            Set the dataField on each datagrid column to the data you want?


            • 3. Objects:  Referencing Values
              Vesta0424 Level 1
              Actually,

              I figured this out on my own. SInce the result is an object, I created a new object var to hold the response. Because the detail of the object was typed as an ArrayCollection, I could then set my Bindable ArrayCollection var to that section of the result. Solution:

              [Bindable]
              private var confirmAC:ArrayCollection = new ArrayCollection;

              private function submitResultHandler(event:* = null):void
              {
              var detailObj:Object = event.target.state[SubmitLeaveCommand.RESULT_NAME];
              var tempAC:ArrayCollection = detailObj.details.detail;
              }


              Thanks for all the replies