I am trying to alter a drop down Enum option list depending on the incoming value to the edit screen. The drop down changes as expected when the screen displays, but when I select an option I get the following error (if it isn’t the first Enum list):
ConversionException: Unable to convert value of type com.solutiondomain.fieldsolution.entity.ElectricJobTypes to model type class com.solutiondomain.fieldsolution.entity.WaterJobTypes. No converter is set and the types are not compatible.
Source file attached.
Do I need to convert the field as well somehow when I set the different Enum class?
Could you share a screen XML descriptor and an Entity class?
An exception is thrown because you are trying to set a selected option to the tasktype field. Check that your enumerations are inheritors of a type of the tasktype property.
I’m not sure I was trying to do something that was possible, essentially I want a property to be an Enum but depending on what is selected, only show a sub set of the Enum in the dropdown selector. E.g.
Option1
Option2
Option3
OptionA
OptionB
OptionB
If the user selects “numbers” only show Option1-3 in the dropdown and if they select “letters” show OptionsA-C
What is the best way of doing that? Is an Enum appropriate?
It depends on your business logic. General idea is to iterate over enumeration values, filter and collect them to some list. Then you can just invoke lookupField.setOptionsList(listWithFilteredOptions).