Join David Gassner for an in-depth discussion in this video Displaying validation errors with the Spark Form component, part of Flash Builder 4.5 and Flex 4.5 New Features.
- View Offline
The Spark Form container and its child object the FormItem now…handle validator display.…In this version of the application that you can import from the Validation.fxp…file in 03_spark, I've implemented a validator for the drop-down list.…Let's take a look at the code.…I'll go to Source mode and show you that there is an instance of the…NumberValidator class.…Its source property is set to ddlTours, that's the id of the drop-down list, and…the property to selectedIndex.…
The minValue has been set to 0, meaning that an item must be selected in the…drop-down list to be considered valid, and the LessThanMinError that would be…triggered if the value is negative one, that's the value of selected index if…nothing is selected. It gives me a message of Please select a tour.…And then I have added conditional code in the find_clickHandler here.…I'm getting an event object typed as ValidationResultEvent by calling the…validator object's validate method, and then examining its type and if it's…valid I'm changing the state and displaying the selected item.…
Recommended prerequisite: Flash Builder 4 and Flex 4 Essential Training.
- Coding with Quick Assist
- Using code completion on metadata tags and states
- Using new Design mode configuration and view capabilities
- Using the Spark versions of the DataGrid, Form, and Image components
- Creating a Flex project for Android applications
- Handling navigation in a view-based mobile application
- Using the Flash Catalyst CS5.5/Flash Builder 4.5 workflow