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 ofAuthorProxy, 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
setAcceptableValuesautomatically adds the current value (returned bygetValue, and defaults tonull) to the list (andsetValueautomatically adds the value to the list of acceptable values too if needed), so make sure you passnullas an acceptable value, or you callsetValuewith a value from the list before callingsetAcceptableValues.