public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
System.out.println("Prepare MultiboxActionForm ....");
/*
* Prepare a String array of color names used to generate
* checkboxes using html:multibox tags in the JSP page.
*/
String[] colors =
{ "Red", "Orange", "Yellow", "Green", "Blue", "Indigo", "Violet" };
request.setAttribute("colors", colors);
/*
* Set default checkbox values.
*/
String[] defaultFruits = { "Orange", "Banana", "Apple" };
String[] defaultColors = { "Orange", "Yellow" };
MultiboxActionForm multiboxForm = (MultiboxActionForm) form;
multiboxForm.setFruits(defaultFruits);
multiboxForm.setColors(defaultColors);
// Return an ActionForward to the form
return mapping.findForward("success");
}
|