Announcement Announcement Module
Collapse
No announcement yet.
How to use the built in ConditionalGenericConverter implemented classes Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to use the built in ConditionalGenericConverter implemented classes

    I wanted to bind a String[] field to my page, for doing that I started going through the documentation with Spring 3.

    Finally I found a built-in convertor org.springframework.core.convert.support.StringToA rrayConverter which looked a close match to my need, but since it implements the ConditionalGenericConverter interface, in order to use this class as given in the javadocs that it executes conditionally.

    Below is the javadocs I found on the interface class:
    A generic converter that conditionally executes.

    Applies a rule that determines if a converter between a set of convertible types matches given a client request to convert between a source field of convertible type S and a target field of convertible type T.

    Often used to selectively match custom conversion logic based on the presence of a field or class-level characteristic, such as an annotation or method. For example, when converting from a String field to a Date field, an implementation might return true if the target field has also been annotated with @DateTimeFormat.

    As another example, when converting from a String field to an Account field, an implementation might return true if the target Account class defines a public static findAccount(String) method.
    However it is no where clear what is the condition for using the built-in StringToArrayConverter class

  • #2
    My bad, I posted the query in a hurry. I was able to see that this is happening automatically within the framework without any extra logic.

    It was my view(freemarker template) which was expecting a string and got an array was the one complaining.

    Comment

    Working...
    X