1 package org.rcfaces.core.component;
2
3 import org.rcfaces.core.internal.component.Properties;
4 import org.rcfaces.core.internal.capability.IConvertValueHolder;
5 import org.rcfaces.core.component.capability.IUnlockedClientAttributesCapability;
6 import org.apache.commons.logging.LogFactory;
7 import java.lang.String;
8 import org.rcfaces.core.component.AbstractCommandComponent;
9 import javax.faces.context.FacesContext;
10 import javax.faces.convert.Converter;
11 import javax.el.ValueExpression;
12 import java.util.HashSet;
13 import org.apache.commons.logging.Log;
14 import java.util.Set;
15 import java.util.Arrays;
16
17
18
19
20 public abstract class AbstractConverterCommandComponent extends AbstractCommandComponent implements
21 IUnlockedClientAttributesCapability,
22 IConvertValueHolder {
23
24 private static final Log LOG = LogFactory.getLog(AbstractConverterCommandComponent.class);
25
26 protected static final Set CAMELIA_ATTRIBUTES=new HashSet(AbstractCommandComponent.CAMELIA_ATTRIBUTES);
27 static {
28 CAMELIA_ATTRIBUTES.addAll(Arrays.asList(new String[] {"unlockedClientAttributeNames","converter"}));
29 }
30
31
32 public void setConverter(String converterId) {
33
34
35 setConverter(null, converterId);
36
37 }
38
39 public void setConverter(FacesContext facesContext, String converterId) {
40
41
42 if (facesContext==null) {
43 facesContext=FacesContext.getCurrentInstance();
44 }
45 Converter converter = facesContext.getApplication().createConverter(converterId);
46 this.setConverter(converter);
47
48 }
49
50 public void setConverter(Converter converter) {
51
52
53 engine.setProperty("converter", converter);
54
55 }
56
57 public Converter getConverter() {
58
59
60 return (Converter)engine.getProperty("converter", null);
61
62 }
63
64 public Converter getConverter(FacesContext facesContext) {
65
66
67 return (Converter)engine.getProperty("converter", facesContext);
68
69 }
70
71 public Object getLocalValue() {
72
73
74 return engine.getLocalValue(Properties.VALUE);
75
76 }
77
78 protected Set getCameliaFields() {
79 return CAMELIA_ATTRIBUTES;
80 }
81 }