Using converters in a list with Spring Roo

时光怂恿深爱的人放手 提交于 2019-12-25 00:29:14

问题


Now that I found how to use converters in an HTML SELECT in Spring Roo, I am trying to do the same in a list.

I managed to register a Converter in my ApplicationConversionServiceFactoryBean, but now I need to use it as well when displaying a list of my envities. I have the following entity :

@RooJavaBean
@RooToString
@RooEntity
public class Environment {

    @NotNull
    @Size(min = 2, max = 30)
    private String name;

    @ManyToOne
    private Application application;
}

When displaying it as a list in the generated MVC, it looks like the application is displayed as a toString() and not using the registered converter.

What am I missing ?


回答1:


You need to push-in refactor the Roo generated converter method to the application conversion factory bean.

Sometimes, by default toString() method is used for the conversion.

Alternatively, you can try pushing in and overriding the toString() method within the entity itself. You will have to remove the @RooToString annotation while doing this.

Cheers!!!



来源:https://stackoverflow.com/questions/6664258/using-converters-in-a-list-with-spring-roo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!