| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package javax.faces.webapp; |
| 17 | |
|
| 18 | |
import javax.faces.component.UIComponent; |
| 19 | |
import javax.faces.internal.WebAppUtil; |
| 20 | |
import javax.servlet.jsp.JspException; |
| 21 | |
import javax.servlet.jsp.tagext.TagSupport; |
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
public class AttributeTag extends TagSupport { |
| 27 | |
|
| 28 | |
private static final long serialVersionUID = 1L; |
| 29 | |
|
| 30 | 0 | private String name = null; |
| 31 | |
|
| 32 | 0 | private String value = null; |
| 33 | |
|
| 34 | 0 | public AttributeTag() { |
| 35 | 0 | } |
| 36 | |
|
| 37 | |
public void setName(String name) { |
| 38 | 0 | this.name = name; |
| 39 | 0 | } |
| 40 | |
|
| 41 | |
public void setValue(String value) { |
| 42 | 0 | this.value = value; |
| 43 | 0 | } |
| 44 | |
|
| 45 | |
public int doStartTag() throws JspException { |
| 46 | 0 | UIComponentTag componentTag = UIComponentTag |
| 47 | |
.getParentUIComponentTag(pageContext); |
| 48 | 0 | if (componentTag == null) { |
| 49 | 0 | throw new JspException("Not nested in a UIComponentTag"); |
| 50 | |
} |
| 51 | 0 | UIComponent component = componentTag.getComponentInstance(); |
| 52 | 0 | if (component == null) { |
| 53 | 0 | throw new JspException( |
| 54 | |
"No component associated with UIComponentTag"); |
| 55 | |
} |
| 56 | 0 | String nameObj = name; |
| 57 | 0 | if (UIComponentTag.isValueReference(name)) { |
| 58 | 0 | nameObj = (String) WebAppUtil.getValueFromCreatedValueBinding(name); |
| 59 | |
} |
| 60 | 0 | Object valueObj = value; |
| 61 | 0 | if (UIComponentTag.isValueReference(value)) { |
| 62 | 0 | valueObj = WebAppUtil.getValueFromCreatedValueBinding(value); |
| 63 | |
} |
| 64 | 0 | if (component.getAttributes().get(nameObj) == null) { |
| 65 | 0 | component.getAttributes().put(nameObj, valueObj); |
| 66 | |
} |
| 67 | 0 | return SKIP_BODY; |
| 68 | |
} |
| 69 | |
|
| 70 | |
public void release() { |
| 71 | 0 | name = null; |
| 72 | 0 | value = null; |
| 73 | 0 | } |
| 74 | |
} |