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?

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.

Can you be more specific? What wiring are you trying to do with a combobox or icon button? As far as adding additional methods to better detail the editing process, you can use the ValueAwareEditor<T>, CompositeEditor<T>, HasEditorDelegate<T>, etc interfaces to get more details about the editing process, same as if you are using standard GWT widgets. Beyond that, I'd need to know what you are trying to do.

A ComboBox is a natural for a field - if a bean has a 'size' property, where the value can be 'small', 'medium', or 'large', the ComboBox can be populated with those values. When the user changes the ComboBox and driver.flush() is invoked, the user's selection will be pushed into the bean.

I'm not sure how you want an IconButton to behave as an Editor<T> in a form - can you describe how you would expect that to work?

The relevant parts are the constructor and the method called setRecord. That's where the relevant Node object is passed in and all values assigned. I do driver.edit but also wind up doing a lot of it manually because the ParameterButtons and comboBox don't seem to populate properly. It's not a runnable version because to run it you'd need a ton of our base classes, we have a pretty complex hierarchy of classes.

I suspect one of the issues deals with the comboBox being of type server rather than of type Node. I'm not sure what's wrong with the ParameterButtons. The ScaleBaseFormLayout is just a class of helper methods which create FieldItems of various types with consolidated and reused code (we were trying to make it easy to modify our stylenames, margins, align, etc). I know we would normally do this just by modifying CSS but after a requirement change had me scurry through our codebase and change every single FieldLabel we had I resolved never to go through that again.

The basic idea here is in EditNodeView when I call edit on the driver, I want it to take the serverId from the Node object and use it to set the ComboBox. This doesn't seem to be working.

Our ParameterButtons are our company's replacement for checkboxes. They take in a boolean value (either in the constructor or in setValue) and based on that they change their style which changes their icon. Basically they are a button that say "On" or "Off"

yeah I thought the bug might be something like that. So my question is how to write a method that will special case it. I want to add the glue that will tell the ComboBox to take that int as an Id but I was trying to put it into the Driver class.
Thanks

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.