How to map a BitSet on facesconfig.xml

447 Views Asked by At

I want to map this bean in my facesconfig.xml

public class VisualizationBean {

    private BitSet results;

    public BitSet getResults() {
        return results;
    }

    public void setResults(BitSet results) {
        this.results = results;
    }

}

As I saw in some articles and some examples, it is possible to initialize maps or other fields, but I can't figure out how to initialize this fiel. I guess something similar to

 <managed-bean>
        <managed-bean-name>visualizationBean</managed-bean-name>
        <managed-bean-class>path.bean.VisualizationBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
        <managed-property>
            <property-name>results</property-name>
            <map-entries>
                <map-entry>
                    <key>true</key>
                    <value>6</value>
                </map-entry>
                <map-entry>
                    <key>false</key>
                    <value>12</value>
                </map-entry>
                <map-entry>
                    <key>false</key>
                    <value>24</value>
                </map-entry>                
            </map-entries>
        </managed-property>        
    </managed-bean>

But htis is not correct. Any help?? Thanks in advance

1

There are 1 best solutions below

3
On BEST ANSWER

You can't. The BitSet doesn't implement Map and JSF doesn't provide facilities to preset other managed property data structures than List or Map.

You have basically 2 options:

  1. Use a Map<Object, Boolean> instead (note that you need to inverse the keys/values in your faces-config.xml; keys are supposed to be unique!)

  2. Fill the BitSet yourself during bean's (post)construction based on some other external file, like a .properties file.