2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.shale.clay.parser.builder;
22
23 import org.apache.shale.clay.config.beans.AttributeBean;
24 import org.apache.shale.clay.config.beans.ComponentBean;
25 import org.apache.shale.clay.config.beans.ElementBean;
26 import org.apache.shale.clay.config.beans.SymbolBean;
27 import org.apache.shale.clay.parser.Node;
28
29 /***
30 * <p>
31 * This {@link Builder} will create a target
32 * {@link org.apache.shale.clay.config.beans.ElementBean} for a "<a>"
33 * {@link Node}. The mapping between the html and the builder is handled by the
34 * {@link AnchorBuilderRule}.
35 * </p>
36 */
37 public class OutputLinkBuilder extends Builder {
38
39 /***
40 * <p>
41 * Returns a JSF component type of <code>javax.faces.HtmlOutputLink</code>.
42 * </p>
43 *
44 * @param node markup
45 * @return component type
46 */
47 protected String getComponentType(Node node) {
48 return "javax.faces.HtmlOutputLink";
49 }
50
51 /***
52 * <p>
53 * Returns a <code>jsfid</code> that will populate the target
54 * {@link org.apache.shale.clay.config.beans.ElementBean}.
55 * </p>
56 *
57 * @param node markup
58 * @return jsfid
59 */
60 protected String getJsfid(Node node) {
61 return "outputLink";
62 }
63
64 /***
65 * <p>
66 * Returns <code>true</code> meaning that the target JSF component can
67 * have children.
68 * </p>
69 *
70 * @return <code>true</code>
71 */
72 public boolean isChildrenAllowed() {
73 return true;
74 }
75
76 /***
77 * <p>Calls super to populate the <code>target</code> config bean with the
78 * html <code>node</code>'s values. The "href" attribute doesn't have a
79 * corresponding outputLink value so it will become a symbol. If there
80 * is a "value" attribute, connect the component's "value" to the
81 * "@href" symbol.</p>
82 *
83 * @param node markup node
84 * @param target config bean
85 * @param root parent config bean
86 */
87 protected void encodeBegin(Node node, ElementBean target, ComponentBean root) {
88 super.encodeBegin(node, target, root);
89
90 AttributeBean attr = target.getAttribute("value");
91 SymbolBean symbol = target.getSymbol("href");
92 if ((symbol != null && attr != null)
93 && (attr.getValue() == null || attr.getValue().length() == 0)) {
94 createAttribute(attr, "@href", target);
95 }
96 }
97
98 }