1 Reply Latest reply: Nov 29, 2012 4:00 AM by jmsjr RSS

    JAXB -- Mapping a Boolean to generate getter method instead of isXXX method

    jmsjr
      Is there a way to have JAXB generate a getter method ( e.g. getXXX() ) for a java.lang.Boolean instead of an isXXXX() method ?
      The reason I need it to generate getXXX() instead of isXXX() for a java.lang.Boolean is because of a bug in the Introspector, which causes it not to "see" the isXXX() method as a readable property, as per the following JIRA:

      https://issues.apache.org/jira/browse/EL-13


      For example, given the following ( which was generated from a WSDL via wsimport ):
      public class DocumentDetail
          implements Serializable
      {
          protected Boolean requiredForInsurerSubmission;
      
          public Boolean isRequiredForInsurerSubmission() {
              return requiredForInsurerSubmission;
          }
      
          public void setRequiredForInsurerSubmission(Boolean value) {
              this.requiredForInsurerSubmission = value;
          }
      }
      If you then have an EL expression in a JSF page with ( where claimDocument is a DocumentDetail as per above ):
      <h:selectBooleanCheckbox id="claimDocForInsurerSubmission" value="#{claimDocument.requiredForInsurerSubmission}"/>
      .. you get the following error:
      20:06:56,851 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http--0.0.0.0-8081-2) Error Rendering View[/contacts.xhtml]: javax.el.PropertyNotFoundException: /contacts.xhtml @89,103 value="#{claimDocument.requiredForInsurerSubmission}": The class 'au.com.xxx.bpm.insuranceclaims.member.v1.DocumentDetail' does not have a readable property 'requiredForInsurerSubmission'.
              at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111) [jsf-impl-2.1.7-jbossorg-2.jar:]
      Yes, I could manually change the generated code so that the isXXX() method becomes a getXXX() method, but the changes will get lost, and possibly forgottem, if the WSDL is updated.

      Thus, the need to generate a getter instead of an isXXX() method.
        • 1. Re: JAXB -- Mapping a Boolean to generate getter method instead of isXXX method
          jmsjr
          jmsjr wrote:
          Is there a way to have JAXB generate a getter method ( e.g. getXXX() ) for a java.lang.Boolean instead of an isXXXX() method ?
          The reason I need it to generate getXXX() instead of isXXX() for a java.lang.Boolean is because of a bug in the Introspector, which causes it not to "see" the isXXX() method as a readable property, as per the following JIRA:

          https://issues.apache.org/jira/browse/EL-13


          For example, given the following ( which was generated from a WSDL via wsimport ):
          public class DocumentDetail
          implements Serializable
          {
          protected Boolean requiredForInsurerSubmission;
          
          public Boolean isRequiredForInsurerSubmission() {
          return requiredForInsurerSubmission;
          }
          
          public void setRequiredForInsurerSubmission(Boolean value) {
          this.requiredForInsurerSubmission = value;
          }
          }
          If you then have an EL expression in a JSF page with ( where claimDocument is a DocumentDetail as per above ):
          <h:selectBooleanCheckbox id="claimDocForInsurerSubmission" value="#{claimDocument.requiredForInsurerSubmission}"/>
          .. you get the following error:
          20:06:56,851 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (http--0.0.0.0-8081-2) Error Rendering View[/contacts.xhtml]: javax.el.PropertyNotFoundException: /contacts.xhtml @89,103 value="#{claimDocument.requiredForInsurerSubmission}": The class 'au.com.xxx.bpm.insuranceclaims.member.v1.DocumentDetail' does not have a readable property 'requiredForInsurerSubmission'.
          at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:111) [jsf-impl-2.1.7-jbossorg-2.jar:]
          Yes, I could manually change the generated code so that the isXXX() method becomes a getXXX() method, but the changes will get lost, and possibly forgottem, if the WSDL is updated.

          Thus, the need to generate a getter instead of an isXXX() method.
          Never mind, got it:

          -enableIntrospection option in xjc

          http://java.net/jira/browse/JAXB-131