DateChooser onChange and formatting the date

PMembrey
PMembrey used Ask the Experts™
on
Hi,

I want to trigger an event whenever the user changes (select a new) date from the datechooser. I've tried onchange(), onclick() and others - but the event was only triggered once on the first change - on the second change, it didn't send out a new HTTP request.

Also, how can I get from datechooser a date in the format of:

YYYMMDD

Thanks in advance!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Hi,
Why you need it to send HTTPRequest for change event?

You can use DateFormatter for formatting date. Example for change is in http://livedocs.adobe.com/flex/3/langref/mx/controls/DateChooser.html.

Thanks,
Vindys

Author

Commented:
Hi,

because I want to automatically reload the data that's being displayed. It's basically a modified version of your original example. The problem is, after you change the date, the data updates, but only once...

Commented:
Hi,

So I think you having a DateChooser and you want it to send HTTPRequest when ever user change the date.
If you getting change event for DateChooser everytime when date is changed, why you not able to send HTTPRequest? Or you mean its not firing change event each time? Can you share some code snippet?

Thanks,
Vindys
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
I'm on a mobile phone so I don't have the code handy. Basically onclick calls a method similar to the init() in your last example which requests the new URL. The callback is left the same as init. However this only works once. Clicking another date doesn't show a hit on the server...

Author

Commented:
The DateChooser looks like this:

  <mx:DateChooser x="526" y="10" click="updateData()"/>

and my updateData() method is:


                    private function updateData():void{
                          
                                  
                                var loader:URLLoader = new URLLoader(new URLRequest("http://localhost/data.php?date=20100120"));
                        loader.addEventListener(Event.COMPLETE, callbackGetXMLRequest);  
                               
                         
                       
                    }


the callback method is the same as the one you provided and the same as the one that initially loads the data.

When the apps starts, it loads the correct data. When I pick a new date, it loads the new data - but if I click another date after that, it doesn't work and I can't figure out why...

Adding the datechooser is the only modification I've made to the example app provided.
Commented:
Hi,

Why you hitting same request each time? "http://localhost/data.php?date=20100120"

I think its some sort of security measure from your server thats not allowing it to respond for same request again as it can be from an attack. Alternative would be to add a timestamp with your request so that it won't be the same request from same client.

To make sure this is the trouble, you can put an Alert in your UpdateData() and see if its showing each time.

Thanks,
Vindys

Author

Commented:
It turned out that the events were being fired and the handler called, just it wasn't sending the request to the server. Once I set up the dynamic side (setting the date), it started working fine.

It was putting the trace in the callback handler and action that helped me track down the problem though.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial