2013-04-24 83 views
1

因爲兩天我面對PrimeFaces 3.5 selectOneMenu對象的奇怪問題。 我在這個體系結構中使用EJB項目中的JPA + EJB + JAX-WS,並使用Web項目中的JAX-WS服務創建客戶機。然後將Web服務客戶端封裝到ManagedBean中,以便與我的PrimeFaces接口綁定。 我ManagedBean如下:primefaces 3.5 selectonemenu不顯示數據

import java.util.List; 
import javax.ejb.Stateless; 
import javax.inject.Named; 
import tg.moov.imereport.service.DownStream; 
import tg.moov.imereport.service.DownStreamWSService; 


@Named 
@Stateless 
public class DownStreamMBean { 
    private DownStreamWSService service; 

    public DownStreamMBean() { 
     service = new DownStreamWSService(); 
    } 

    public List<DownStream> getDownStreamsService() { 
     return service.getDownStreamWSPort().getDownStreams(); 
    } 

} 

和selectOneMenu用於代碼如下:

<h:form> 
    <p:selectOneMenu value="#{downStreamTotalMBean.ds.IDDownStream}"> 
    <f:selectItems value="#{downStreamMBean.downStreamsService}" var="item" 
     itemValue="#{item.IDDownStream}" itemLabel="#{item.nom}"/>       
    </p:selectOneMenu> 
</h:form> 

這裏是下游類:

package tg.moov.imereport.service; 

import javax.xml.bind.annotation.XmlAccessType; 
import javax.xml.bind.annotation.XmlAccessorType; 
import javax.xml.bind.annotation.XmlElement; 
import javax.xml.bind.annotation.XmlType; 


/** 
* <p>Java class for downStream complex type. 
* 
* <p>The following schema fragment specifies the expected content contained within this class. 
* 
* <pre> 
* &lt;complexType name="downStream"> 
* &lt;complexContent> 
*  &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> 
*  &lt;sequence> 
*   &lt;element name="IDDownStream" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> 
*   &lt;element name="IPAddress" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> 
*   &lt;element name="login" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> 
*   &lt;element name="nom" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> 
*   &lt;element name="password" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> 
*   &lt;element name="path" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> 
*  &lt;/sequence> 
*  &lt;/restriction> 
* &lt;/complexContent> 
* &lt;/complexType> 
* </pre> 
* 
* 
*/ 
@XmlAccessorType(XmlAccessType.FIELD) 
@XmlType(name = "downStream", propOrder = { 
    "idDownStream", 
    "ipAddress", 
    "login", 
    "nom", 
    "password", 
    "path" 
}) 
public class DownStream { 

    @XmlElement(name = "IDDownStream") 
    protected String idDownStream; 
    @XmlElement(name = "IPAddress") 
    protected String ipAddress; 
    protected String login; 
    protected String nom; 
    protected String password; 
    protected String path; 

    /** 
    * Gets the value of the idDownStream property. 
    * 
    * @return 
    *  possible object is 
    *  {@link String } 
    *  
    */ 
    public String getIDDownStream() { 
     return idDownStream; 
    } 

    /** 
    * Sets the value of the idDownStream property. 
    * 
    * @param value 
    *  allowed object is 
    *  {@link String } 
    *  
    */ 
    public void setIDDownStream(String value) { 
     this.idDownStream = value; 
    } 

    /** 
    * Gets the value of the ipAddress property. 
    * 
    * @return 
    *  possible object is 
    *  {@link String } 
    *  
    */ 
    public String getIPAddress() { 
     return ipAddress; 
    } 

    /** 
    * Sets the value of the ipAddress property. 
    * 
    * @param value 
    *  allowed object is 
    *  {@link String } 
    *  
    */ 
    public void setIPAddress(String value) { 
     this.ipAddress = value; 
    } 

    /** 
    * Gets the value of the login property. 
    * 
    * @return 
    *  possible object is 
    *  {@link String } 
    *  
    */ 
    public String getLogin() { 
     return login; 
    } 

    /** 
    * Sets the value of the login property. 
    * 
    * @param value 
    *  allowed object is 
    *  {@link String } 
    *  
    */ 
    public void setLogin(String value) { 
     this.login = value; 
    } 

    /** 
    * Gets the value of the nom property. 
    * 
    * @return 
    *  possible object is 
    *  {@link String } 
    *  
    */ 
    public String getNom() { 
     return nom; 
    } 

    /** 
    * Sets the value of the nom property. 
    * 
    * @param value 
    *  allowed object is 
    *  {@link String } 
    *  
    */ 
    public void setNom(String value) { 
     this.nom = value; 
    } 

    /** 
    * Gets the value of the password property. 
    * 
    * @return 
    *  possible object is 
    *  {@link String } 
    *  
    */ 
    public String getPassword() { 
     return password; 
    } 

    /** 
    * Sets the value of the password property. 
    * 
    * @param value 
    *  allowed object is 
    *  {@link String } 
    *  
    */ 
    public void setPassword(String value) { 
     this.password = value; 
    } 

    /** 
    * Gets the value of the path property. 
    * 
    * @return 
    *  possible object is 
    *  {@link String } 
    *  
    */ 
    public String getPath() { 
     return path; 
    } 

    /** 
    * Sets the value of the path property. 
    * 
    * @param value 
    *  allowed object is 
    *  {@link String } 
    *  
    */ 
    public void setPath(String value) { 
     this.path = value; 
    } 

} 

Web服務正常工作和顯示數據,但selectOneMenu不顯示任何內容。 請有人幫助我。如果需要,我可以提供更多信息。

問候。

+0

你可以張貼tg.moov。 imereport.service.DownStream?我想知道什麼toString實現看起來像那個類(如果它已被覆蓋) – 2013-04-24 12:41:04

+0

我剛剛用DownStream JPA類更新了我的第一篇文章。提前致謝 ! – 2013-04-24 12:51:41

+0

對不起,它是來自tg.moov.imereport.service的DownStream。 – 2013-04-24 12:57:34

回答

0

您需要爲selectOneMenu上的自定義類使用轉換器。

見BalusC他的解釋,這裏objects in selectonemenu

在primefaces的<p:selectOneMenu>converter=""屬性,你可以用它來轉換器,而不是過多鏈接不必增加它的seperatly使用<f:converter>

+0

感謝您的反饋。在我的情況下,由於'item.nom'是一個字符串,我想我不需要使用'converter =「」'屬性。我會嘗試並回到你身邊。 – 2013-04-24 13:11:52

+0

我有同樣的結果。 – 2013-04-24 13:19:30

+0

我懷疑我的豆註釋。但似乎一切都是正確的。 – 2013-04-24 13:25:52

相關問題