Java Reference
In-Depth Information
Figure 15.7: Initial form before selecting a car make
Using Partial Forms
By now you've realized that using Ajax and updating page fragments is
easy and fun but also introduces new challenges. Another one of these
is the use of page fragments with form input controls that are to be
inserted back into an existing form, after an Ajax request.
car make and model. After a make is selected in the first box, an Ajax
request is sent to update the models in the second box. The result after
the car make select box triggers an Ajax request with the make sent
as a parameter. The server responds with the car model select box,
populated with the models that correspond to the selected car make.
The model and action bean for this example are straightforward:
package
stripesbook.model;
public class
Cars
extends
HashMap<String,List<String>> {
public
Cars() {
put("Acura", Arrays.asList("CSX", "MDX", "TL", "TSX"));
put("Ford", Arrays.asList("Escape", "Explorer", "Focus", "Mustang"));
put("Honda", Arrays.asList("Accord", "Civic", "CR-V", "S2000"));
put("Porsche", Arrays.asList("911 Carrera", "Boxster"));
}
}
Search WWH ::
Custom Search