因为两天我面临与PrimeFaces 3.5 selectOneMenu对象的奇怪问题。 我在EJB项目中使用此体系结构JPA + EJB + JAX-WS,并在Web项目中从JAX-WS服务创建客户端。然后将Web Service Client封装在ManagedBean中以与我的PrimeFaces接口绑定。 我的ManagedBean如下:
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>
这是DownStream类:
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>
* <complexType name="downStream">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="IDDownStream" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="IPAddress" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="login" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="nom" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="password" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="path" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </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 :(得分:0)
您需要在selectOneMenu上为自定义类使用转换器。
请参阅BalusC在此处的解释objects in selectonemenu
在primefaces中,<p:selectOneMenu>
有一个converter=""
属性,您可以使用该属性来链接转换器,而不必使用<f:converter>