JAXB boolean handling oddities and JSF

Posted by finrod on Stack Overflow See other posts from Stack Overflow or by finrod
Published on 2010-06-10T14:10:48Z Indexed on 2010/06/10 14:12 UTC
Read the original article Hit count: 449

Filed under:
|
|
|
|

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:

  1. setXXX(Boolean value) is generated
  2. 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.

© Stack Overflow or respective owner

Related posts about java

Related posts about jsf