2012-10-15 43 views
1

我有一個由JAXB生成的集合,我想將它關聯到一個selectManyListbox以進行多選。selectManyListbox for jaxb collection

這裏是JSF:

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

,這是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; 
    } 

} 

的問題是,所產生的JAXB類的收藏價值二傳手值的缺乏和TextValueLookup類generateb當提交selectManyListbox(ajax或form)時,會拋出以下錯誤:

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

任何解決方法?

回答

0

好吧,這個註釋在XSD做的伎倆:

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

現在收集是一個String [](不是List),並有getter和setter。

這樣,我已經定義了唯一一個集我的架構作爲索引,但與其他THI註釋,我們可以爲所有的集合指定:

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

希望這有助於。

再見