findForward("missing-data");
}
if (formatBean.isMissing(formatBean.getFgColor())) {
addMessage(messages, "fg", "Missing Foreground Color");
forward = mapping.findForward("missing-data");
} else if (formatBean.getFgColor().equals
(formatBean.getBgColor())) {
Chapter 12 ?– The Struts Framework: Validating User Input 604
addMessage(messages, "fg",
"Foreground and Background Identical!");
forward = mapping.findForward("missing-data");
}
if (!messages.isEmpty()) {
addMessages(request, messages);
}
return(forward);
}
protected void addMessage(ActionMessages messages,
String property,
String warning) {
messages.add(property, new ActionMessage(warning, false));
}
}
Listing 12.4 chooseFormat1/WEB-INF/struts-config.xml
"-//Apache Software Foundation//DTD Struts Configuration 1.3//
EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
type="coreservlets.FormatFormBean"/>
type="coreservlets.ShowSampleAction"
name="formatFormBean"
scope="request">
path="/WEB-INF/results/resume.jsp"/>
path="/forms/form1.jsp"/>
...
Listing 12.3
chooseFormat1/WEB-INF/classes/coreservlets/
ShowSampleAction.
Pages:
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653