The “srv” instance is declared at the top of the factory and is a valid instance of
the object “Services” which has a member called “assignedTo” which is of type “User”.
The “ContainerUtils” call creates a BeanItemInstance for the class passed in and it is filtered according to the parameters. This works fine and the correct values are present.
I’ve tried all sorts of variations in other forum posts and nothing works to select the value
in the combo. The value is definitely there- already debugged the instance to confirm that.
“User” implements equals and hashCode.
The problem is that the internal call to setValue(Object, boolean) always returns false. No matter what I pass in as the property id- the actual string instance of the name, or the whole User object.
Any help would be much appreciated.
Regards,
Anthony
I’m not quite sure what your problem could be. What type does the getAssignedTo() return? I think it should work with the User object, assuming that the container is a BeanItemContainer. What is the BeanItemInstance you mention?
Anyhow,
this example does much the same thing and works. The getIdByIndex() returns the bean object, as it is used as the item ID in the BIC.
I suspect that your equals() or hashCode() do not behave quite like the framework expects.
However, if your User beans have some natural identifier, I’d recommend using a BeanContainer instead of a BeanItemContainer. That way, you can explicitly give IDs or generate them from the beans.
I’ll try that. the equals & hasCode do have explicit unqiue ids to work from, so I don’t think that’s the problem, which I’ve had in the past, so I catch that one early one.
I’ll try the BeanContainer instead of the BeanItemContainer.