GWT编辑器框架:下拉列表 [英] GWT Editor Framework: Drop Down List

查看:126
本文介绍了GWT编辑器框架:下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找某人为我指出正确方向(链接),或者提供了一个代码示例,用于使用 RequestFactory 以及 GWT 中的 Editor 框架。我的项目中的一个模型有多对一的关系:

  @Entity 
public class Book {

@ManyToOne
私人作者作者;
}

当我构建视图添加/编辑书籍时,我想要显示一个可以用来选择哪个作者写这本书的下拉列表。如何用编辑器框架完成这项工作?

解决方案

下拉列表中,您需要一个 ValueListBox< AuthorProxy> ,它恰好是 AuthorProxy 的编辑器,所以一切都很好。但是,您需要填充列表( setAcceptableValues ),因此您可能需要向服务器发送请求以加载作者列表。



'p>当心 setAcceptableValues 自动将电流值(由的getValue 返回,并且默认为 null )到列表中(如果需要, setValue 会自动将该值添加到可接受值列表中) ,所以请确保您传递 null 作为可接受的值,或者使用列表中的值调用 setValue > 之前调用 setAcceptableValues


I'm looking for someone to point me in the right direction (link) or provide a code example for implementing a drop down list for a many-to-one relationship using RequestFactory and the Editor framework in GWT. One of the models for my project has a many to one relationship:

@Entity
public class Book {

  @ManyToOne
  private Author author;
}

When I build the view to add/edit a book, I want to show a drop down list that can be used to choose which author wrote the book. How can this be done with the Editor framework?

解决方案

For the drop-down list, you need a ValueListBox<AuthorProxy>, and it happens to be an editor of AuthorProxy, so all is well. But you then need to populate the list (setAcceptableValues), so you'll likely have to make a request to your server to load the list of authors.

Beware the setAcceptableValues automatically adds the current value (returned by getValue, and defaults to null) to the list (and setValue automatically adds the value to the list of acceptable values too if needed), so make sure you pass null as an acceptable value, or you call setValue with a value from the list before calling setAcceptableValues.

这篇关于GWT编辑器框架:下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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