Accessibility

Flex sample application

Flex 3 Restaurant Finder

The Restaurant Finder application is a demo application that shows how to use the Adobe Flex SOAP web-service support for CRUD operations in a master-detail type application. The default state shows a list of all restaurants in the database. When you click a restaurant, the details about that restaurant and summaries of reviews appear. When you select a summary, the details of the review appear. You can add reviews to the review list. You can also filter the list of restaurants by restaurant type. This application is also accessible to users with disabilities. You can use the application with the keyboard alone, and the contents can be read by a screen reader. Since this application has a fairly linear flow of control, it was well suited to change into an accessible application.

There is also a second application, Recent Reviews, that shows how to use RESTful web services in addition to SOAP-based web services. This application displays the 10 most recent restaurant reviews. From the Recent Reviews application, click the restaurant name; the Restaurant Finder application opens with the restaurant selected. A small component like this could be a useful addition to a larger site like a portal.

Experience the application

To download and view the full source, right-click the Flex application and select View Source from the context menu.

File and folder descriptions

Setting up the project in Flex Builder 3

  1. Click the Experience the application link above to view the application.
  2. Right-click on the application and select View Source from the context menu.
  3. Click the link to Download Source in the lower-left corner of the window. This downloads a zipped archive of the project, RestaurantFinderFlex3.zip.
  4. Import the RestaurantFinderFlex3 project into your Flex Builder workspace by selecting File > Import > Flex Project from the main menu.
  5. Make sure the "Archive file" radio button is selected and press the Browse button to launch the Open dialog box.
  6. In the Open dialog box, navigate to the RestaurantFinderFlex3.zip file and click the Open button to select the file and dismiss the dialog box.
  7. Click the Finish button to finish importing the project into your current workspace.

    Note: Three non-default settings were used in creating the project:

    • Accessibility was enabled by selecting Project > Properties > Flex Compiler and checking Generate accessible SWF file.
    • HTML wrapper files were not generated for the project by selecting Project > Properties > Flex Compiler and unchecking Generate HTML wrapper file. When you select a restaurant in the Recent Reviews application, the Restaurant Finder application is opened in a browser window with the restaurant selected that was selected in the Recent Reviews application. To achieve this, the selected restaurant is passed as a URL variable to the Restaurant Finder application when it is opened from the Recent Reviews application. The default HTML file was altered to pass the URL variable to the SWF using flashvars.
    • Custom launch configurations were created so that the proper HTML files could be opened instead of the SWF files when you run either the RestaurantFinder.mxml or RecentReviews.mxml files which is what happens by default if you do not have Flex Builder automatically creating HTML wrapper files. These were not retained, however, when the project was exported for release and need to be recreated by you.
  8. Run the application. Note that the SWF file is opened in the default SWF viewing application for your computer.
  9. Select Run > Run > Other.
  10. In the Create, manage, and run configurations dialog box, make sure the application file is set to RestaurantFinder.mxml.
  11. Uncheck the Use defaults check box under URL or path to launch.
  12. Change the Debug, Profile, and Run URLs from RestaurantFinder.swf to RestaurantFinder.html with the same paths.
  13. Click the Apply button.
  14. Click the new launch configuration button in the upper-left corner of the dialog box.
  15. Give the new configuration the name RecentReviews.
  16. Select the RestaurantFinderFlex3 project.
  17. Select the RecentReviews.mxml application file.
  18. Uncheck the Use defaults check box under URL or path to launch.
  19. Change the Debug, Profile, and Run URLs from RecentReviews.swf to RecentReviews .html with the same paths.
  20. Click the Apply button.
  21. Click the Run button. The Recent Reviews application should open in a browser window.
  22. Click the name of one of the restaurants. The Restaurant Finder application should open in a new browser window with that restaurant selected.

Installation and deployment instructions

By default, the two applications use Adobe hosted services. The Restaurant Finder application uses hosted SOAP services at the following URLs:

http://www.adobe.com/go/flex_restaurant_category_service?wsdl

http://www.adobe.com/go/flex_restaurant_restaurant_service?wsdl

Note: The hosted web services are behind a load-balancer and the different computers behind the load balancer maintain their own copies of the database. Therefore, reviews that you add in one instance of the application may not appear the next time you run the application. If this happens, you can refresh the application in your browser to try to access the correct database instance.

The hosted Restful web service used by the Recent Reviews application has the following URL:

http://www.adobe.com/go/flex_restaurant_recent_reviews

To use a local deployment of the services instead, you need to deploy the provided Java and JSP files to your server and then edit the appropriate AS and MXML files in the application. The Java and JSP files are located in the WEB-INF folder in the RestaurantFinderFlex3 project. You can use Ant to build a WAR file that contains everything you need or build the Java classes and then copy the RecentReviews.jsp and WEB-INF folder into an existing WAR. You will need to adjust your wsdl URLs according to the WAR file's context path and your servlet container's port. The source code for the SOAP services is in the WEB-INF/src folder and all services use a local HSQL DB located in the WEB-INF/db folder.

To change the location of the SOAP web services for the Restaurant Finder application, open the /com/adobesamples/restaurant/controller/ServiceLocator.as file, replace the URL in both of the lines that contain "ws.wsdl = ", and then recompile the application.

To change the location of the REST service for the Recent Reviews application, open RecentReviews.mxml, replace the url in the HTTPService, and then recompile the RecentReviews.mxml application.

Flex framework and architecture features