Boolean column does not show in table

I have the following class gererated by a tool (xjc). Please notice the getter of the boolean property is “isATLASAlignment”. The prefix is “is” instead of “get”.

package com.test.hello;
import javax.xml.bind.annotation.XmlElement;
public class TestBoolean {

@XmlElement(name = "RegistrationNumber")
protected String registrationNumber;

@XmlElement(name = "ItemNumber")
protected Integer itemNumber;
@XmlElement(name = "ATLASAlignment")
protected Boolean atlasAlignment;

public String getRegistrationNumber() {
    return registrationNumber;
}
public void setRegistrationNumber(String registrationNumber) {
    this.registrationNumber = registrationNumber;
}
public Integer getItemNumber() {
    return itemNumber;
}
public void setItemNumber(Integer itemNumber) {
    this.itemNumber = itemNumber;
}
public Boolean [b]

isATLASAlignment
/b {
return atlasAlignment;
}

public void setATLASAlignment(Boolean value) {
    this.atlasAlignment = value;
}

}

I use the following code to create a atble and can see only two columns. The boolean column is not there.

private Table createTable() {
    Table table = new Table();
    table.setContainerDataSource(new BeanItemContainer<TestBoolean>(TestBoolean.class));
    
    String[] headers = table.getColumnHeaders();
    
    return table;
}

Is there any way to work around? Because there are many boolean fields in different beans, I don’t want to change from isATLASAlignment to getATLASAlignment.

The only thing I can see, is discrepancy in case, between property and setter/getter. But it should not be a problem. Try to rename methods
isATLASAlignment
and
setATLASAlignment
to
isAtlasAlignment
and
setAtlasAlignment
respectively, to be sure it is not a problem.

Lacking a better solution, if you use Maven you can easily download sources and delve into vaadin code with the debugger. Check in the BeanItem related classes and there you should find where the method name is build to call it via reflection.

Get the file and bring it to your project inside the very same package structure and redo the part where boolean properties getters are build with ‘get’ instead of ‘is’. Override it and you’re done. The class loader will preceede your file instead of the original one.

That should make it.

However I am unaware if there are any legal aspects you have to consider with regard to your project. Bear that in mind.

Good luck.
Carlos.

The tool I am using is “xjc.exe”. Can I get source code from some place?

Sorry, you must have misunderstood me. I meant to override the default Vaadin file where the method name is generated. It has to be a BeanItemXXX file…

Carlos.

Thank you so much. Let me do some research and see if I can find a solution.

This seems to be a bug in JAXB:
You should be able to ‘fix’ the problem by providing the parameter ‘-enableIntrospection’ when running XJC.

See
https://www.ibm.com/developerworks/community/blogs/Dougclectica/entry/JAXB_with_Java_7_and_xs_boolean?lang=en
for more details.

wenxiang that seems a much better solution… thanks Kai.

Carlos.

It works perfect. Thanks Kai and everybody.