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.internal.component;
21
22 import org.apache.myfaces.tobago.component.SupportFieldId;
23 import org.apache.myfaces.tobago.component.SupportsAccessKey;
24 import org.apache.myfaces.tobago.component.Visual;
25 import org.apache.myfaces.tobago.util.ComponentUtils;
26
27 import javax.faces.component.UICommand;
28 import javax.faces.component.UIComponent;
29 import javax.faces.component.UIInput;
30 import javax.faces.component.behavior.ClientBehaviorHolder;
31 import javax.faces.context.FacesContext;
32
33
34
35
36 public abstract class AbstractUICommand extends AbstractUICommandBase
37 implements SupportsAccessKey, Visual, ClientBehaviorHolder, SupportFieldId {
38
39 enum PropertyKeys {
40 disabled,
41 }
42
43
44 private Boolean parentOfCommands;
45
46 public boolean isParentOfCommands() {
47 if (parentOfCommands == null) {
48 parentOfCommands = false;
49 for (final UIComponent child : getChildren()) {
50 if (child.isRendered()
51 && !(child instanceof AbstractUIEvent)
52 && (child instanceof UICommand || child instanceof UIInput)) {
53 parentOfCommands = true;
54 break;
55 }
56 }
57 }
58 return parentOfCommands;
59 }
60
61 @Override
62 public abstract String getLabel();
63
64 @Override
65 public String getFieldId(final FacesContext facesContext) {
66 if(isParentOfCommands()) {
67 return getClientId(facesContext) + ComponentUtils.SUB_SEPARATOR + "command";
68 } else {
69 return getClientId(facesContext);
70 }
71 }
72 }