PDA

View Full Version : [FIXED] Triggerfield bug with setReadonly and setEditable



Colin Alworth
20 May 2009, 1:07 PM
Steps to reproduce
Create a triggerfield (or subclass)
Set the field as not editable (so that the text cannot be changed directly)
Set the field as not readonly (i.e. was once readonly, and now isn't)Expected behavior: trigger button can be used to edit, but text field section cannot
Actual behavior: both trigger button and text field can be modified

Sample code:

ComboBox<MyObj> field = new ComboBox<MyObj>();
field.setStore(new ListStore<MyObj>());
field.getStore().add(myObjList);

field.setEditable(false);

...

field.setReadOnly(false);I tried to chase down a fix, or at least a workaround, I havent managed to get one, even when waiting for the render event, and then calling setEditable(true) setEditable(false). I'd guess that it has something to do with the fact that the editable property interacts with readonly, and that my test case here assumes that all code runs before render time, but I think I'm out of my depth.

Thanks,
Colin

Colin Alworth
21 May 2009, 6:52 PM
Workaround:

The issue stems from the fact that setReadOnly affects the results of the setEditable command.

In my case, I cannot reverse the calls, but if you call

field.setReadOnly(false);
field.setEditable(false);the problem will not present itself.

Additionally, if (as in my case) you have to call

field.setEditable(false);
field.setReadOnly(false);then because of some clever code in setEditable that prevents the same value from being set twice, you need to call


field.setEditable(true);
field.setEditable(false);

Hope this helps the gxt devs, and maybe other people the trigger field and its subclasses.

sven
8 Jun 2009, 2:34 PM
Steps to reproduce
Create a triggerfield (or subclass)
Set the field as not editable (so that the text cannot be changed directly)
Set the field as not readonly (i.e. was once readonly, and now isn't)Expected behavior: trigger button can be used to edit, but text field section cannot
Actual behavior: both trigger button and text field can be modified

Sample code:

ComboBox<MyObj> field = new ComboBox<MyObj>();
field.setStore(new ListStore<MyObj>());
field.getStore().add(myObjList);

field.setEditable(false);

...

field.setReadOnly(false);I tried to chase down a fix, or at least a workaround, I havent managed to get one, even when waiting for the render event, and then calling setEditable(true) setEditable(false). I'd guess that it has something to do with the fact that the editable property interacts with readonly, and that my test case here assumes that all code runs before render time, but I think I'm out of my depth.

Thanks,
Colin



setEditable(false) means that oyu cant edit the field and only select from the dropdown. Why are you setting readOnly to false than again? That means that you can again edit the field. I would not count this as a bug.

Colin Alworth
8 Jun 2009, 3:17 PM
The usecase is where:
I have a field on the screen (a dropdown, and I need the user to select an option, but may not type in their own).
After user input, something causes the field to be marked readonly- the user may not edit it again.
Some other interaction takes place, and once again interaction is allowed with the field (but as a non-editable ComboBox, the user may not enter arbitrary text).At 3), for any other Field<?> that I deal with, I only should have to call setReadOnly(boolean) - I should not need to deal with the field as a trigger field. Let these three steps exist in a usecase where I have several fields of varying types, all subject to any arbitrary ruleset to allow and disallow editing. I would consider behavior that forces me to discover which kind of field I am dealing with in order to call Field.setReadOnly(boolean).

Unless there is another way to do this that I am unaware of, I think that this actually is a bug.

sven
27 Aug 2009, 1:24 AM
Fixed in SVN.