I followed the instructions:
-
create the bean. This bean is for an enum transferred from server to client using RestyGWT.
public enum Mode{ MODIFY, EDIT, DELETE, CREATE } -
Define the marker on the bean.
@BEAN(Mode.class) static public class ModelMarker implements BeanModelMarker { } -
(Paraphrasing a statement from GXT blog) Now use your BeanModelMarker on any data component.
So, I created a combo box.
static private ComboBox<ModelMarker> propertyTypeComboBox = new ComboBox<ModelMarker>();Ooops, the ComboBox does not accept BeanModelMarker as a Model type. And it certainly is wrong, because it has not been GWT created yet.
And so what do I do with a GWT created instance?
static ModelMarker beanModel =
GWT.create(ModelMarker.class);
I am unable to find any literature that tells me explicitly what to do with a BeanModelMarker after it is defined. How do I use it?
I would like to know what I need to do to define a Bean or Base Model, so that I could use the enum in my data-driven combobox.
Am I asking the question in the right way about BeanModelMarker? Is it relevant to my attempt at creating an enum-driven combo box?
Couple of thoughts:
Here is a discussion on the GXT forums about wrapping
enumtypes in ComboBoxes. http://www.sencha.com/forum/showthread.php?67317-Enum-based-ComboBox. Several approaches are used – in that thread, I went with the approach of making an EnumWrapper, and some static convenience methods to createList<EnumWrapper<MyEnum>>collections to give to the combo box ListStore. One of the main reasons that I went for that as opposed to a BeanModel approach was that I needed my enums to be i18n-capable, and didn’t want that i18n logic in the enum itself.More pertinent to your question, the correct way to translate a java object to a BeanModel is to use the
BeanModelFactoryinstance provided fromBeanModelLookup.getFactory(Mode.class).ModelMarkeris just an interface, and can’t implementModelData, so yourComboBox<ModelMarker>declaration doesn’t really make sense. Remember that using this approach means yourModeenum needs to expose getters so theBeanModelgeneration code can work its reflection-ish magic (like in http://www.sencha.com/forum/showthread.php?67317-Enum-based-ComboBox&p=332996&viewfull=1#post332996).