Tuesday, November 22, 2011

flex surprises again (this time with datefield)

In my "update" screen (in flex), I'm getting the actual date value from the model and showing it to the user. If the user changes this date value in the screen, no problem; it's working. But if he doesn't touch this date field then the value of it is null as far as I can see while debugging.

In my update screen this is the part I define the datefield.
< mx:DateField id="endingDateDatefield" text="{formatDate(myModel.endingDate)}" 
formatString="{FORMAT_STRING}" width="50%" height="25"/> 
                                  
Notice that formatDate() returns String.

The datefield is displayed correctly but when I try to save the new model I saw no value in debug. "parentPanel.endingDateDatefield.selectedDate" is null.
So I changed my code to:
< mx:DateField id="endingDateDatefield" selectedDate="{myModel.endingDate}" 
formatString="{FORMAT_STRING}" width="50%" height="25"/> 

Now I set the selectedDate field instead of text in DateField component which fixes the issue.

No comments:

Post a Comment