6 Replies Latest reply on Mar 10, 2008 4:44 AM by daniel.soneira

    rich:Calendar custom converter doesn't work

    rconaway

      I'm trying to register a custom converter for a rich:calendar component. It does not seem to recognize the converter. I have tried specifying both a property that returns a converter and the id of a converter that has been registered in faces-config.

      To figure out what's wrong, I have created a trivially simple converter that just throws an exception. I have been able to successfully use this converter with an h:inputText tag, so I'm pretty confident that the converter is written correctly and registered correctly.

      Can someone either confirm that 1) there is a bug in rich:calendar or 2) help me with an example that works?

      As always, I appreciate any help.

      Rob

      Here is the rich:calendar code:

      <rich:calendar
       value='#{claimSearch.dob}'
       popup='true'
       datePattern='M/dd/yyyy'
       enableManualInput='true'
       converter='ifx.myconverter' />
      


      Here is similar h:inputText code which recognizes the converter:
      <h:inputText
       value='#{claimSearch.lastName}'
       converter='ifx.myconverter' />
      


      Here is the registration of the converter in faces-config:
      <converter>
       <converter-id>ifx.myconverter</converter-id>
       <converter-class>ifx.web.MyConverter</converter-class>
      </converter>
      


      Here is the implementation of MyConverter:
      package ifx.web;
      import javax.faces.application.FacesMessage;
      import javax.faces.component.UIComponent;
      import javax.faces.context.FacesContext;
      import javax.faces.convert.Converter;
      import javax.faces.convert.ConverterException;
      
      public class MyConverter implements Converter {
       public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
       FacesMessage message = new FacesMessage("'" + arg2 + "' cannot be converted");
       throw new ConverterException(message);
       }
       public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
       return "01/01/2007";
       }
      }