01: /**
02: *
03: */package nl.hippo.cms.wizard.aspects;
04:
05: import nl.hippo.cms.wizard.Constants;
06: import nl.hippo.cms.wizard.components.Configuration;
07: import nl.hippo.cms.wizard.components.Component;
08: import nl.hippo.cms.wizard.components.ComponentContainer;
09: import nl.hippo.cms.wizard.widgets.Widget;
10:
11: /**
12: * @author a.bogaart@hippo.nl
13: *
14: */
15: public abstract class AbstractComponentAspect implements
16: ComponentAspect {
17:
18: protected Component component;
19: private Object value = null;
20: private boolean useComponent = false;
21:
22: public void configure(Configuration config) throws Exception {
23: if (config.get(Constants.VALUE_ATTRIBUTE_NAME) != null) {
24: value = config.get(Constants.VALUE_ATTRIBUTE_NAME);
25: } else {
26: useComponent = true;
27: }
28: }
29:
30: public void setComponent(Component component) {
31: this .component = component;
32: }
33:
34: public Component getComponent() {
35: return this .component;
36: }
37:
38: public String getValue() {
39: if (!useComponent) {
40: return value.toString();
41: } else if (component instanceof Widget) {
42: Widget widget = (Widget) component;
43: return widget.getValue().toString();
44: } else if (component instanceof ComponentContainer) {
45: ComponentContainer container = (ComponentContainer) component;
46: return container.getCurrent();
47: }
48: return "";
49: }
50:
51: }
|