Converters

Converters are utility classes that convert from an object to a showable object on the screen and the other way around. Say you have a Date object in your bean, it should eg convert the date object to the "readable" format of the date like : 12-12-2003. If the user types eg 12-12-2004, the convert should convert the value to a valid Date object. It always returns null when conversion is impossible. By using converters we avoid very complicated dictionary entries and a lot of hard to test code in nyx to handle this in another (automatic) fashion.

How to write converters

You can create converters by implementing the interface IConverter The code speaks for itself. For an example, have a look at the code of the default converters in the org.xulux.dataprovider.converters package.

How to add converters

You can add converters via the dictionary xml file in the format

      
      <converters>
        <converter class="org.xulux.nyx.converters.IntegerConverter"/>
      </converters>
      
      
or by calling
        Dictionary.addConverter(ConvertClass);
      
in your code.

If you don't use the use attribute in the gui xml, you can also set the converter of the field using in the field definition. Xulux will use this converter in all cases, except when using the use attribute.