This content has been marked as final.
Show 3 replies
-
1. Re: Converter Problems (one-way two-way)
mail.micke Aug 11, 2008 6:43 PM (in response to accless)Can you post the code for the converter, might be able to spot something there.
If there is a stack trace please post that as well.Have you debugged your converter to make sure that it creates the objects properly?
-micke
-
2. Re: Converter Problems (one-way two-way)
accless Aug 12, 2008 11:54 AM (in response to accless)public class QuotationPeriodConverter implements Converter { public Object getAsObject(FacesContext context, UIComponent component, String obj) { obj = obj.trim(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { Date date = sdf.parse(obj); System.out.println("Converted Date: " + date); return date; } catch (ParseException e) { e.printStackTrace(); throw new ConverterException("Parsen von " + obj + " schlug fehl"); } } public String getAsString(FacesContext context, UIComponent component, Object obj) { if (true) return obj.toString(); try { String string = DateUtils.format(((QuotationPeriod)obj).getBeginDate()); System.out.print("String: " + string); return string; } catch(Exception e) { e.printStackTrace(); throw new ConverterException("String-Umwandlung fehlgeschlagen"); } }
the code works fine, as far as i see. Note that i convert from QuotationPeriod (getAsString) to Date(getAsObject)!
greetings
-
3. Re: Converter Problems (one-way two-way)
mail.micke Aug 13, 2008 8:58 PM (in response to accless)Hi
Only used converters with simple MyObj to-and-from String mapping (not MyObj to String to Date).
On vacation now so I can't experiment, but I'd suggest debugging and looking at the types of the converters parameters.
- micke