JAXB boolean handling oddities and JSF
- by finrod
There is a known bug in JAXB: https://jaxb.dev.java.net/issues/show_bug.cgi?id=733
JAXB does not properly generate boolean field getters and setters, this bug is left unfixed for backwards compatibility.
A JAXB plugin exists and will ensure that the following getters and setters for boolean fields are generated:
setXXX(Boolean value) is generated
getXXX() is generated
If the boolean attribute specifies default value in the XSD, then getXXX() returns boolean,
If the boolean attribute does not specify default in the XSD, then getXXX() returns Boolean.
Problem: trying to edit/view the XXX field in a JSF component (such as checkbox) does not work - the component is disabled.
I have not traced this in depth but the assumption (backed by the workaround below) is that JSF EL resolver (or whathaveyou) looks for Boolean getXXX() method and since it does not find it, the component is disabled.
Workaround: If I change the getXXX() method to always return Boolean, then everything goes.
Questions:
What are your ideas to address this problem?
Have I missed some customization for the boolean-getter JAXB plugin?
Is it possible (does it make sense) to alter JSF resolver (or whathaveyou) so that if Boolean getXXX() is not found, it will fall back to boolean getXXX()?
I would prefer not to manually intervene and change all the generated getXXX() methods to return Boolean instead of boolean.