Classes Converter [closed]

0

I have studied programming in JSF , li that for objects to be transformed into String it takes a Convert to entity.

Is there a class ready and we adapt our Entities? How does it work?

    
asked by anonymous 04.10.2016 / 14:01

1 answer

2

You can create a class that implements the interface Converter , in it we can define how the data will be converted, this way you customize this conversion.

By steps: Create a class that implements the javax.faces.contert.Converter interface and is annotated with @facesConverter . A converter is a class that can transform strings into objetos and objetos into strings , so this class should implement methods getAsObject() and getAsString() ;

The getAsObject() method should convert from String to objeto , in this case you can throw an exception of type ConverterException ;

The getAsString() method should convert from objeto to String .

Answering your main question, when implementing Converter you only need to apply conversion logic to methods.

    
04.10.2016 / 14:26