简体   繁体   English

Flash Builder:如何验证datechooser组件中是否已选择日期?

[英]Flash Builder: How to verify if the date has been selected in datechooser component?

I am trying to verify if the users select a date in my date chooser spark componet. 我正在尝试验证用户是否在我的日期选择器spark componet中选择了一个日期。 I tried: 我试过了:

if(dateChooserBegin.selectedDate){
..........
}

I will get a run time null object error. 我将得到一个运行时空对象错误。 I was wondering if anyone here know to do this. 我想知道这里是否有人知道这样做。 Thanks for the help. 谢谢您的帮助。

You will probably need to extract the date from the CalendarLayoutChangeEvent event object that is raised on choosing a particular date. 您可能需要从选择特定日期时引发的CalendarLayoutChangeEvent事件对象中提取日期。 See the example on Flex livedocs (particularly the useDate event handler. 请参阅Flex livedocs上的示例 (特别是useDate事件处理程序)。

Best way I can think of is adding on to what dirkgently said. 我能想到的最好的方法是添加到dirkgently说的内容。 Set on onChange event on the dateChooser to change a global boolean value to true. 在dateChooser上设置onChange事件,将全局布尔值更改为true。 Then in your if() check if the boolean is true. 然后在if()中检查boolean是否为true。 Only other method I can think of to ensure that ANY date is set is to use a selectedDate on the dateChooser itself, forcing a default date in there. 我只能想到确保设置任何日期的其他方法是在dateChooser本身上使用selectedDate,在那里强制使用默认日期。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM