01: /*
02: * Created on Jul 28, 2005
03: */
04: package uk.org.ponder.rsf.components;
05:
06: import uk.org.ponder.rsf.request.EarlyRequestParser;
07: import uk.org.ponder.rsf.viewstate.ViewParameters;
08: import uk.org.ponder.stringutil.StringList;
09: import uk.org.ponder.util.UniversalRuntimeException;
10:
11: /**
12: * Represents a Form (submission domain) in the component tree. Forms are
13: * treated somewhat unusually in that they (may be) generated <it>inline</it> in the
14: * component tree by the producer, but are <it>folded away</it> before they
15: * are seen by the renderer. The form model applied by the target render
16: * technology is embodied by the FormModel, held in the parent View object,
17: * also as a request-scope bean.
18: * @author Antranig Basman (antranig@caret.cam.ac.uk)
19: *
20: */
21: public class UIForm extends UIContainer {
22:
23: /** Which type of submission will this form trigger? For ACTION_REQUEST,
24: * this will behave like a UICommand (e.g. HTTP POST) - for RENDER_REQUEST
25: * like UILink (e.g. HTTP GET).
26: */
27: public String type = EarlyRequestParser.ACTION_REQUEST;
28:
29: /** The target view state of this form. For a managed form, this will be
30: * filled in by the fixup phrase to be the current view state.
31: */
32: public ViewParameters viewparams;
33:
34: /** The URL to which this form will be submitted. This field will be computed
35: * by a fixup and need not be filled in by the user.
36: */
37: public String targetURL;
38:
39: /** A list of the FullIDs of the all controls to be submitted by this form.
40: * If this is left blank(empty), it will be filled in by a FormFixer
41: * (currently by looking for all nested controls that are bound). Each of
42: * these controls will be either a UICommand or a UIBound.
43: * <p> For the HTML submission model, this field is not strictly required
44: * since hidden fields are rendered "alongside" their corresponding controls,
45: * but is useful for general consistency and bookkeeping. More relevant, say,
46: * for "WAP-like" submission models.
47: */
48: public StringList submittingcontrols;
49:
50: /** Creates an "action" form that will receive an RSF submission */
51: public static UIForm make(UIContainer parent, String ID) {
52: if (!(parent instanceof UIBranchContainer)) {
53: throw UniversalRuntimeException
54: .accumulate(new IllegalArgumentException(
55: "Immediate parent of UIForm must be a branch container"));
56: }
57: UIForm togo = new UIForm();
58: togo.ID = ID;
59: togo.noID = true;
60: parent.addComponent(togo);
61: return togo;
62: }
63:
64: /** Creates an "unmanaged" GET ({@link EarlyRequestParser#RENDER_REQUEST})
65: * form, targetted at the supplied ViewParameters */
66:
67: public static UIForm make(UIContainer parent, String ID,
68: ViewParameters viewparams) {
69: UIForm togo = make(parent, ID);
70: togo.viewparams = viewparams.copyBase();
71: togo.type = EarlyRequestParser.RENDER_REQUEST;
72: togo.noID = true;
73: return togo;
74: }
75:
76: /** Creates a form of the specified submission type, either
77: * {@link EarlyRequestParser#ACTION_REQUEST} or {@link EarlyRequestParser#RENDER_REQUEST}.
78: */
79: public static UIForm make(UIContainer parent, String ID, String type) {
80: UIForm togo = make(parent, ID);
81: togo.type = type;
82: togo.noID = true;
83: return togo;
84: }
85:
86: }
|