1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.seasar.teeda.core.taglib.core; |
17 | |
|
18 | |
import javax.faces.component.UIComponent; |
19 | |
import javax.faces.component.UIOutput; |
20 | |
import javax.faces.webapp.UIComponentBodyTag; |
21 | |
import javax.servlet.jsp.JspException; |
22 | |
import javax.servlet.jsp.tagext.BodyContent; |
23 | |
|
24 | |
import org.seasar.teeda.core.JsfConstants; |
25 | |
import org.seasar.teeda.core.util.BindingUtil; |
26 | |
import org.seasar.teeda.core.util.ConverterUtil; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
public class VerbatimTag extends UIComponentBodyTag { |
33 | |
|
34 | |
private static final String COMPONENT_TYPE = "javax.faces.Output"; |
35 | |
|
36 | |
private static final String RENDER_TYPE = "javax.faces.Text"; |
37 | |
|
38 | 5 | private String escape = null; |
39 | |
|
40 | |
public VerbatimTag() { |
41 | 5 | super(); |
42 | 5 | } |
43 | |
|
44 | |
public String getComponentType() { |
45 | 1 | return COMPONENT_TYPE; |
46 | |
} |
47 | |
|
48 | |
public String getRendererType() { |
49 | 5 | return RENDER_TYPE; |
50 | |
} |
51 | |
|
52 | |
public void setEscape(String escape) { |
53 | 1 | this.escape = escape; |
54 | 1 | } |
55 | |
|
56 | |
public String getEscape() { |
57 | 2 | return escape; |
58 | |
} |
59 | |
|
60 | |
protected void setProperties(UIComponent component) { |
61 | 2 | super.setProperties(component); |
62 | 2 | final String escapeStr = getEscape(); |
63 | 2 | if (escapeStr != null) { |
64 | 1 | if (BindingUtil.isValueReference(escapeStr)) { |
65 | 0 | BindingUtil.setValueBinding(component, |
66 | |
JsfConstants.ESCAPE_ATTR, escapeStr); |
67 | |
} else { |
68 | 1 | boolean escape = ConverterUtil.convertToBoolean(escapeStr); |
69 | 1 | component.getAttributes().put(JsfConstants.ESCAPE_ATTR, |
70 | |
escape ? Boolean.TRUE : Boolean.FALSE); |
71 | |
} |
72 | |
} else { |
73 | 1 | component.getAttributes().put(JsfConstants.ESCAPE_ATTR, |
74 | |
Boolean.FALSE); |
75 | |
} |
76 | 2 | component.setTransient(true); |
77 | 2 | } |
78 | |
|
79 | |
public int doAfterBody() throws JspException { |
80 | 1 | BodyContent bodyContent = getBodyContent(); |
81 | 1 | if (bodyContent != null) { |
82 | 0 | String value = bodyContent.getString().trim(); |
83 | 0 | if (value != null) { |
84 | 0 | UIOutput component = (UIOutput) getComponentInstance(); |
85 | 0 | component.setValue(value); |
86 | |
} |
87 | |
} |
88 | 1 | return super.doAfterBody(); |
89 | |
} |
90 | |
|
91 | |
} |