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.
To download and view the full source, right-click the Flex application and select View Source from the context menu.
Click the Finish button to finish importing the project into your current workspace.
Note: Three non-default settings were used in creating the project:
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.
SOAP web services: The Restaurant Finder shows how simple it is to build CRUD applications on top of SOAP web services. Serialization and deserialization of SOAP requests and responses are automatically handled by Flex (though you'll see that we do convert some objects into strongly typed classes on our own). Developers interact with SOAP services in a simple remote procedure call (RPC) manner, dealing with objects, not SOAP packets, headers, and so on.
RESTful web services: The Recent Reviews application shows how easy it is to use an HTTPService to get data from the server. Although you could use the data directly, this application creates a strongly typed class that provides type safety in other parts of the application.
View states and transitions: The ReviewThumbnail class
contains summary and detail views and illustrates how you can use states in
components to edit in context. It also uses transitions to control the
appearance of moving from one state to another.
Accessibility: This demo shows how to build an application that
is accessible to users with disabilities; you can use the application with the
keyboard alone and the contents can be read by a screen reader. For the
standard accessible framework components, communicating with the screen reader
is accomplished easily by setting a tooltip. The screen reader will
automatically read the tooltip when the component receives focus. For
components that have to be modified to be made accessible, screen reader
messages can be controlled through accessibilityProperties or by creating
an accessibilityImplementation.
The use of accessibilityProperties is demonstrated in ReviewThumbnail and accessibilityImplementation is used for the custom accessible Labels, Images, and Text components. For
keyboard access, the tabIndex property was used to control tab order
for an application with a dynamic user interface. The ReviewThumbnail component demonstrates one approach to ensuring proper tab order when states
introduce additional complexity. You can use data binding to assign to the tabIndex,
which simplifies the task tremendously. In addition, in order to allow users to
tab through all of the components, traditionally non-focusable components had
to be made focusable. The application includes an accessible version of the
Label, Image and Text classes, along with an AccImpl helper class
that controls screen reader interactions. The techniques used for these classes
can be extended for making other accessible components.
Custom Repeater component: The list of reviews does not use the
standard Repeater component. The standard Repeater refreshes all of the children
when its dataProvider changes. This behavior had a negative performance impact
for this application. Instead, the application uses a custom repeater-like
class, ThumbnailRepeater, which only creates the children when the whole list
of reviews changes. When you add a review, only one new child is created,
instead of all the children being recreated. By not using a standard Flex
component, traditional list functionality had to be implemented. This included
adding keyboard navigation between rows and taking that navigation into account
for proper scrolling. Scrolling was implemented by keeping track of the current
pane pixel range and adjusting verticalScrollPosition when the selected
item was outside the range.
Loose-coupling of components: The entire application maintains loose coupling of components to maximize component reuse.
Centralizing services: This application includes a simple ServiceLocator class, which demonstrates one technique for centralizing your remote data access.
This ServiceLocator class re-uses the same service objects from multiple components without passing
them around. This is only one approach to this problem; for example, with more
services, a different system might be appropriate.
RPC Responders: The Restaurant Finder application handles service results by using the Responder approach instead of listening for events. This allows finer-grained control over each response. This approach is also useful when using centralized services so that you don't necessarily hear events for calls that weren't related to your component.