01: /*
02: * Created on Nov 27, 2005
03: */
04: package uk.org.ponder.rsf.componentprocessor;
05:
06: import java.util.HashSet;
07: import java.util.Iterator;
08: import java.util.Set;
09:
10: import uk.org.ponder.rsf.components.UIBound;
11: import uk.org.ponder.rsf.components.UICommand;
12: import uk.org.ponder.rsf.components.UIComponent;
13: import uk.org.ponder.rsf.components.UIForm;
14: import uk.org.ponder.util.Logger;
15:
16: /** Debugging processor that notes non-submitting controls that expect to be
17: * submitting.
18: * @author Antranig Basman (antranig@caret.cam.ac.uk)
19: *
20: */
21: public class OrphanFinder implements ComponentProcessor {
22: private Set expectsubmit = new HashSet();
23: private Set submitting = new HashSet();
24:
25: public void processComponent(UIComponent toprocesso) {
26: if (toprocesso instanceof UIBound) {
27: UIBound toprocess = (UIBound) toprocesso;
28: if (toprocess.valuebinding != null && toprocess.fossilize
29: && toprocess.willinput) {
30: expectsubmit.add(toprocess.getFullID());
31: }
32: } else if (toprocesso instanceof UICommand) {
33: expectsubmit.add(toprocesso.getFullID());
34: } else if (toprocesso instanceof UIForm) {
35: UIForm toprocess = (UIForm) toprocesso;
36: submitting.addAll(toprocess.submittingcontrols);
37: }
38: }
39:
40: public void report() {
41: for (Iterator cit = expectsubmit.iterator(); cit.hasNext();) {
42: Object key = cit.next();
43: if (!submitting.contains(key)) {
44: Logger.log.warn("Control with full ID " + key
45: + " expects submission "
46: + "but has not been registered with any form");
47: }
48: }
49: }
50: }
|