01: /*
02: * Created on Oct 25, 2005
03: */
04: package uk.org.ponder.rsf.components;
05:
06: import uk.org.ponder.rsf.viewstate.ViewParameters;
07:
08: /**
09: * A specialisation of a {@link UILink} which specifies a navigation target
10: * which is part of the same RSF application. In this case, specification of the
11: * target can be done in the abstract, by way of a ViewParameters object,
12: * allowing "links to self" to be transparently resolved correctly in whatever
13: * the hosting environment is for the current request (servlet, portlet, etc.).
14: * The <code>target</code> field will be filled in by a fixup prior to
15: * rendering.
16: * <p>
17: * Note that the ViewParameters object supplied as argument to the "make" methods
18: * will be copied prior to being added.
19: *
20: * @author Antranig Basman (amb26@ponder.org.uk)
21: *
22: */
23:
24: public class UIInternalLink extends UILink {
25:
26: public static UIInternalLink make(UIContainer parent, String ID,
27: UIBoundString linktext, ViewParameters viewparams) {
28: UIInternalLink togo = new UIInternalLink();
29: togo.ID = ID;
30: togo.linktext = linktext;
31: togo.viewparams = viewparams.copyBase();
32: parent.addComponent(togo);
33: return togo;
34: }
35:
36: public static UIInternalLink make(UIContainer parent, String ID,
37: String text, ViewParameters viewparams) {
38: UIBoundString linktext = null;
39: if (text != null) {
40: linktext = new UIOutput();
41: linktext.setValue(text);
42: }
43: return make(parent, ID, linktext, viewparams);
44: }
45:
46: public static UIInternalLink make(UIContainer parent, String ID,
47: ViewParameters viewparams) {
48: return make(parent, ID, (UIBoundString) null, viewparams);
49: }
50:
51: /** Create a link which, while internal, does not participate in the
52: * ViewParameters system. This is largely useful for unmanaged environments
53: * such as SpringMVC/Cocoon. Cannot be named "make" to avoid clashing with
54: * UILink through ridiculous Java semantics on static methods.
55: */
56: public static UIInternalLink makeURL(UIContainer parent, String ID,
57: String target) {
58: UIInternalLink togo = new UIInternalLink();
59: togo.ID = ID;
60: togo.target = new UIOutput();
61: if (target != null) {
62: togo.target.setValue(target);
63: }
64: parent.addComponent(togo);
65: return togo;
66: }
67:
68: /** ViewParameters representing the navigation target of this link control */
69: public ViewParameters viewparams;
70: }
|