2013-04-24 78 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

相关问题