1
2
3
4 package org.rcfaces.core.item;
5
6 import javax.faces.component.UIComponent;
7 import javax.faces.model.SelectItem;
8
9 import org.rcfaces.core.component.MenuCheckItemComponent;
10 import org.rcfaces.core.component.MenuItemComponent;
11 import org.rcfaces.core.component.MenuRadioItemComponent;
12 import org.rcfaces.core.component.capability.IInputTypeCapability;
13
14
15
16
17
18
19 public class MenuItem extends DefaultItem implements IMenuItem {
20
21 private static final String REVISION = "$Revision: 1.3 $";
22
23 private static final long serialVersionUID = 1262314873491593499L;
24
25 public MenuItem() {
26 }
27
28 public MenuItem(String label, String description, boolean disabled,
29 SelectItem items[]) {
30 super(label, description, disabled, items);
31 }
32
33 public MenuItem(IMenuItem menuItem) {
34 super(menuItem);
35 }
36
37 public MenuItem(MenuItemComponent menuItemComponent) {
38 super(menuItemComponent);
39 }
40
41 protected void setInputType(UIComponent inputComponent) {
42
43 int type = IInputTypeCapability.AS_PUSH_BUTTON;
44
45 if (inputComponent instanceof MenuRadioItemComponent) {
46 type = IInputTypeCapability.AS_RADIO_BUTTON;
47
48
49 String groupName = ((MenuRadioItemComponent) inputComponent)
50 .getGroupName();
51 if (groupName != null) {
52 setGroupName(groupName);
53 }
54
55 } else if (inputComponent instanceof MenuCheckItemComponent) {
56 type = IInputTypeCapability.AS_CHECK_BUTTON;
57 }
58
59 setInputType(type);
60 }
61
62 }