01: package org.emforge.jbpm.web.converter;
02:
03: import javax.faces.component.UIComponent;
04: import javax.faces.context.FacesContext;
05: import javax.faces.convert.Converter;
06: import javax.faces.convert.ConverterException;
07:
08: import org.emforge.xfer.PriorityTO;
09:
10: /** This converter is used in selectItems for Priority
11: * to convert priority object to id and back
12: */
13: public class PriorityIdConverter implements Converter {
14:
15: public Object getAsObject(FacesContext i_context,
16: UIComponent i_component, String i_str)
17: throws ConverterException {
18: Integer id = Integer.valueOf(i_str);
19:
20: PriorityTO priority = PriorityTO.getPriority(id);
21:
22: return priority;
23: }
24:
25: public String getAsString(FacesContext i_context,
26: UIComponent i_component, Object i_obj)
27: throws ConverterException {
28: PriorityTO priority = (PriorityTO) i_obj;
29:
30: return String.valueOf(priority.getValue());
31: }
32:
33: }
|