Answered: GXT and EditorDriver
I'm trying to use the GWT editor driver to reduce boilerplate code. I've been able to get it to work pretty well on TextFields and checkboxes but I haven't been able to get it to work with ComboBoxes or my stateful Icon buttons. I'm guessing that this is because they don't directly match up with GWT's paradigm. I can't prove this but since the bean is holding the ID of the correct ComboBox value rather than the value itself, I think the editor is trying to set the wrong value. I suspect a similar problem with my icon buttons since they have a setValue method but don't extend Field.
My question is how can I special case this? Where do I add methods to say "for these two widgets handle them like this?"
I'm using SimpleBeanEditorDriver and my view implements Editor. Can anyone tell me how to massage the editor to work with the data correctly?
Posted by Colin Alworth
You can provide an implementation of com.sencha.gxt.data.shared.Converter<N, O> to specify that you want to turn a N in the bean to a O in the field. For example, you would make a Converter<Server, Integer> to allow a ComboBox<Integer> to edit a `Integer getServer()`/`void setServer(Integer server)` property.
Then, pass this and the comboBox itself to a ConverterEditorAdapter. It must be package protected or greater, like a normal editor, and it will wrap up the ComboBox (which must be @Ignored then to prevent it from binding to something that doesnt make sense).
In cases like this, where the editor doesn't directly match the property, you should get errors when you run the app in dev mode or when you compile it - are you not getting those?
One last note: You are putting @Ignored on lots of things that probably don't need it. If something doesn't implement either Editor or IsEditor, it won' t be treated as an editor, and doesn't need to be ignored. Also, if something is private, it isn't visible anyway, and doesn't need to be ignored.
Tags for this Thread