IllegalStateException: Unable to change component for bound FieldConfig

I have just upgraded to 6.5.0 and I’m updating my code to use the new FIeldGroup setup. I am trying to replace a text field in the FieldGroup with a LookupField. Here is my code:

LookupField recTypeLookup = (LookupField) componentsFactory.createComponent(LookupField.NAME);
recTypeLookup.setDatasource(custFieldGroup.getDatasource(), "rtype");

I get the error message in the subject. What is the correct way to override the default Text field created by the FieldGroup?

To answer my own question for the next user, I have to set:


in the XML for the fields where I want to override the implementation with setComponent(). It is in the documentation ( under the description of the “custom” property.

1 Like


I’ve just noticed that you use:

(LookupField) componentsFactory.createComponent(LookupField.NAME);

It can be simplified to:


And you can skip unnecessary (LookupField) cast.