There are some great choices out there to choose from when starting a new web development project. Whether you are just doing a simple site or starting your own business. The frameworks, very thankfully, are getting so good. Which one will manage to stand the test of time? The graph below doesn’t mean that the most trend is always going to be the highest one, especially since roo is so fresh and in the past year has been improved dramatically.
Tag Archives: Roo
ConverterNotFound Using Spring Roo
Using Roo has been really awesome! I would recommend it to anyone starting a web project for the first time that really wanted to use Spring and Java.
Just ran into this error tonight and thought I would blog a little bit about it in case others run into the same error… *plus* I wanted to show a bit of this new Google Guava project!
1 2 3 4 | org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from 'java.util.Se t' to 'java.lang.String' at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:181) at org.springframework.expression.spel.support.StandardTypeConverter.convertValue(StandardTypeConverter.java:66) |
This meant that we need a converter for the show view since the default create from Roo does not take care of the ONE_TO_MANY relationship. Below is the code that was needed in my case.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /** * A central place to register application Converters and Formatters. */ @RooConversionService public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean { Converter<Set<Property>, String> getPropertySetConverter() { return new Converter<Set<Property>, String>() { public String convert(Set<Property> properties) { return Joiner.on(",").join(properties.toArray()); // 1 } }; } @Override protected void installFormatters(FormatterRegistry registry) { super.installFormatters(registry); registry.addConverter(getPropertySetConverter()); } } |
Notice the line:
1 | return Joiner.on(",").join(properties.toArray()); // 1 |
This is using the Google Guava project to create a String instead of using the old school StringBuilder approach.