1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.myfaces.tobago.facelets.extension;
21
22 import org.apache.myfaces.tobago.component.Attributes;
23 import org.apache.myfaces.tobago.component.RendererTypes;
24 import org.apache.myfaces.tobago.component.UISelectBooleanCheckbox;
25
26 import javax.el.ValueExpression;
27 import javax.faces.component.UIComponent;
28 import javax.faces.view.facelets.ComponentConfig;
29 import javax.faces.view.facelets.FaceletContext;
30 import javax.faces.view.facelets.TagAttribute;
31
32 public class SelectBooleanCheckboxExtensionHandler extends TobagoLabelExtensionHandler {
33
34 private TagAttribute itemLabelAttribute;
35
36 public SelectBooleanCheckboxExtensionHandler(ComponentConfig config) {
37 super(config);
38 itemLabelAttribute = getAttribute(Attributes.ITEM_LABEL);
39 }
40
41 protected void enrichInput(FaceletContext faceletContext, UIComponent input) {
42 super.enrichInput(faceletContext, input);
43 UISelectBooleanCheckbox checkbox = (UISelectBooleanCheckbox) input;
44 if (itemLabelAttribute != null) {
45 if (itemLabelAttribute.isLiteral()) {
46 checkbox.setItemLabel(itemLabelAttribute.getValue(faceletContext));
47 } else {
48 ValueExpression expression = itemLabelAttribute.getValueExpression(faceletContext, String.class);
49 checkbox.setValueExpression(Attributes.ITEM_LABEL, expression);
50 }
51 } else {
52 checkbox.setItemLabel("");
53 }
54 }
55
56 protected String getSubComponentType() {
57 return UISelectBooleanCheckbox.COMPONENT_TYPE;
58 }
59
60 protected String getSubRendererType() {
61 return RendererTypes.SELECT_BOOLEAN_CHECKBOX;
62 }
63 }