1

i have a collection generated by JAXB that i want to associate to a selectManyListbox for multi-selection.

Here is the JSF:

<h:selectManyListbox value="#{field.textValueLookup.value}"                         size="5" >
 <f:selectItems value="#{consultaController.getOpcionesLookup(field.queryField)}"/>
</h:selectManyListbox>

and this is the TextValueLookup class generateb by JAXB

//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-833 
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2012.10.15 at 06:52:09 PM CEST 
//


package es.ine.iria2.query.jaxb.complexQuery;

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;


/**
 * <p>Java class for anonymous complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType>
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element ref="{http://iria.ine.es/schemas/complexQuery.xsd}value" maxOccurs="unbounded" minOccurs="0"/>
 *       &lt;/sequence>
 *       &lt;attribute name="operator" use="required" type="{http://iria.ine.es/schemas/complexQuery.xsd}TextLookupFilterOperatorType" />
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "value"
})
@XmlRootElement(name = "textValueLookup")
public class TextValueLookup {

    protected List<String> value;
    @XmlAttribute(required = true)
    protected TextLookupFilterOperatorType operator;

    /**
     * Gets the value of the value property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the value property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getValue().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link String }
     * 
     * 
     */
    public List<String> getValue() {
        if (value == null) {
            value = new ArrayList<String>();
        }
        return this.value;
    }

    /**
     * Gets the value of the operator property.
     * 
     * @return
     *     possible object is
     *     {@link TextLookupFilterOperatorType }
     *     
     */
    public TextLookupFilterOperatorType getOperator() {
        return operator;
    }

    /**
     * Sets the value of the operator property.
     * 
     * @param value
     *     allowed object is
     *     {@link TextLookupFilterOperatorType }
     *     
     */
    public void setOperator(TextLookupFilterOperatorType value) {
        this.operator = value;
    }

}

The problem is that the jaxb class generated lacks of a setter value for the value collection and when the selectManyListbox is submitted (ajax or form) it throws this error:

Target Unreachable, 'null' returned null: javax.el.PropertyNotFoundException: /consultaCompleja/seleccionCamposFiltro.xhtml @39,18 value="#{field.textValueLookup.value}": Target Unreachable, 'null' returned null

Any workaround?

4

1 回答 1

0

Ok, this annotation in xsd do the trick:

<xs:annotation>
    <xs:appinfo>
            <jaxb:property collectionType="indexed" />
    </xs:appinfo>
</xs:annotation>

Now the collection is a String[] (not a List) and has getter and setter.

This way i've defined only one collection of my schema as indexed but with thi other annotation we can specify it for all the collections:

<xs:annotation>
    <xs:appinfo>
            <jaxb:globalBindings collectionType="indexed" />
    </xs:appinfo>
</xs:annotation>

Hope this help.

Bye

于 2012-10-16T10:06:41.657 回答