1 Reply Latest reply on Nov 25, 2011 5:21 AM by BobSzabo1

    AsyncToken has null datafields when data field is of type Timestamp, Date or Datetime

    BobSzabo1

      Hello all, I have attempted this with version 4 and version 4.5 of flashbuilder and am having a undesired results.

       

      Essentially I have a simple mysql table:

       

      DROP TABLE IF EXISTS `messages_per_day`;

      CREATE TABLE `messages_per_day` (

        `day` date NOT NULL,

        `count` bigint(20) DEFAULT NULL,

        PRIMARY KEY (`day`)

      ) ENGINE=MyISAM AUTO_INCREMENT=531147206 DEFAULT CHARSET=latin1;

       

       

       

      I have a simple java object that looks like:

       

      @Entity

      @Table(name = "messages_per_day")

      public class MessagesPerDay implements Serializable {

       

                @Id

                private Date day;

                private long count;

       

                public Date getDay() { return day; }

                public void setDay(Date day) { this.day = day; }

                public long getCount() { return count; }

                public void setCount(long count) { this.count = count; }

      }

       

      And a java service class that looks like:

       

      @Component

      @Service("messagesPerDayService")

      @RemotingDestination(channels={"my-amf"})

      @Transactional

      public class MessagesPerDayService

      {

         protected HibernateTemplate template;

       

         @Autowired

          public void setSessionFactory(SessionFactory factory)

          {

              template = new HibernateTemplate(factory);

          }

       

          @SuppressWarnings("unchecked")

          public List<MessagesPerDay> getHistory()

          {

              return (List) template.find("FROM MessagesPerDay where day >= curdate() - 28");

          }

      }

       

       

      These deploy fine into my app server and I can then use FlashBuilders Data/Services tool to generate both the valueObjects and the Services files.  Using the Test Operation function provided I can acess the data and I can see the date showing up.

       

       

       

      Howerver, and here is the crux of the problem.  In flex mxml when I have:

       

      <fx:Declarations>

                          <s:CallResponder id="resultSet"/>

                          <services:MessagesPerDayService id="messagesPerDayService"

              fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"

                                                                                            result="processResult(event)"

                                                                                            showBusyCursor="true"/>

      </fx:Declarations>

       

       

      <fx:Script>

                          <![CDATA[

           private function processResult(event:ResultEvent):void

           {

                                                        var array:Array = ArrayCollection(event.result).source;

                                                        for each(var item:Object in array)

                                                        {

       

                          for (var p:String in item)

                                                                                      logger.debug( "Introspection-> " + p + ": " + item[p]);

                          logger.debug("Count: " + item.count);

                          logger.debug("Day: " + item.day);

       

                                                        }

            }

                          ]]>

      </fx:Script>

       

       

      <mx:DataGrid id="datagrid" height="100%" width="100%"  dataProvider="{resultSet.lastResult}" >

             <mx:columns>

                                                        <mx:DataGridColumn headerText="Day" dataField="day" visible="true" />

                                                        <mx:DataGridColumn headerText="Count" dataField="count" visible="true" />

                                         </mx:columns>   

      </mx:DataGrid>

       

       

      Now the data for count comes out fine and is displayed in both the logger.debug output and in the grid, however the day fields is always null.

       

      Has anyone seen this behaviour? Any Ideas?

        • 1. Re: AsyncToken has null datafields when data field is of type Timestamp, Date or Datetime
          BobSzabo1 Level 1

          Reviewing the flashtxt.log file  I can see that the remote object was retreived successfully, however the formated date cannot be cast to valueObjects.Date

           

           

          11/25/2011 08:17:06.618 [INFO] mx.messaging.Producer '5F9DB7A5-86BD-4443-1107-DADEE4EF42FC' producer acknowledge of '21884EB6-AC56-09E5-604C-DADF475401AB'.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Tue Nov 1 00:00:00 GMT-0400 2011>@a9adc81 to valueObjects.Date.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Wed Nov 2 00:00:00 GMT-0400 2011>@a9add21 to valueObjects.Date.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Thu Nov 3 00:00:00 GMT-0400 2011>@a9add81 to valueObjects.Date.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Fri Nov 4 00:00:00 GMT-0400 2011>@a9adde1 to valueObjects.Date.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Sat Nov 5 00:00:00 GMT-0400 2011>@a9ade41 to valueObjects.Date.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Sun Nov 6 00:00:00 GMT-0400 2011>@a9adea1 to valueObjects.Date.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Mon Nov 7 00:00:00 GMT-0500 2011>@a9adf01 to valueObjects.Date.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Tue Nov 8 00:00:00 GMT-0500 2011>@a64b1e1 to valueObjects.Date.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Wed Nov 9 00:00:00 GMT-0500 2011>@a64b241 to valueObjects.Date.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Thu Nov 10 00:00:00 GMT-0500 2011>@a9adc61 to valueObjects.Date.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Fri Nov 11 00:00:00 GMT-0500 2011>@a9add41 to valueObjects.Date.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Sat Nov 12 00:00:00 GMT-0500 2011>@a9addc1 to valueObjects.Date.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Sun Nov 13 00:00:00 GMT-0500 2011>@a9ade61 to valueObjects.Date.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Mon Nov 14 00:00:00 GMT-0500 2011>@a9adee1 to valueObjects.Date.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Tue Nov 15 00:00:00 GMT-0500 2011>@a64b201 to valueObjects.Date.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Mon Nov 21 00:00:00 GMT-0500 2011>@a64b281 to valueObjects.Date.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Tue Nov 22 00:00:00 GMT-0500 2011>@a64b2e1 to valueObjects.Date.

          TypeError: Error #1034: Type Coercion failed: cannot convert <Wed Nov 23 00:00:00 GMT-0500 2011>@a64b341 to valueObjects.Date.