在 Spring Roo 的列表中使用转换器

发布于 2024-11-19 18:19:33 字数 563 浏览 9 评论 0原文

现在我找到了 如何在 Spring Roo 中的 HTML SELECT 中使用转换器< /a>,我正在尝试在列表中执行相同的操作。

我设法在我的 ApplicationConversionServiceFactoryBean 中注册了一个转换器,但现在我在显示我的嫉妒列表时也需要使用它。我有以下实体:

@RooJavaBean
@RooToString
@RooEntity
public class Environment {

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

    @ManyToOne
    private Application application;
}

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

我缺少什么?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

星星的軌跡 2024-11-26 18:19:33

您需要将 Roo 生成的转换器方法推入重构为应用程序转换工厂 bean。

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

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

干杯!!!

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!!!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文