在Spring Roo的列表中使用转换器 [英] Using converters in a list with Spring Roo

查看:79
本文介绍了在Spring Roo的列表中使用转换器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我发现了如何在HTML SELECT中使用转换器Spring Roo ,我正在尝试在列表中进行同样的操作.

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.

我设法在ApplicationConversionServiceFactoryBean中注册了一个Converter,但现在在显示我的环境列表时也需要使用它.我有以下实体:

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;
}

在生成的MVC中将其显示为列表时,看起来该应用程序显示为toString()而不使用注册的转换器.

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.

我想念什么?

推荐答案

您需要将Roo生成的转换器方法推送到应用程序转换工厂bean中.

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

有时,默认情况下,使用toString()方法进行转换.

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

或者,您可以尝试推入并覆盖实体本身内的toString()方法.执行此操作时,您将必须删除@RooToString批注.

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.

干杯!

这篇关于在Spring Roo的列表中使用转换器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆