você tem que implementar uma classe de converter(conversão) a seguir um exemplo junto ao seu p:selectOneMenu
<p:selectOneMenu id="n1" value="#{clienteBean.cliente.cartao}" converter="ClienteConversor" > <f:selectItems value="#{clienteBean.clientes}" var="cliente" itemLabel="#{cliente.nome}" /> </p:selectOneMenu>
PessoaConverte package org.salomao.conversor;
import java.io.Serializable;
import javax.enterprise.context.ApplicationScoped;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.inject.Named;p:selectOneMenu
import org.salomao.model.cliente;
<p:selectOneMenu id="n1" value="#{clienteBean.cliente.cartao}" converter="ClienteConversor" >
<f:selectItems value="#{clienteBean.clientes}" var="cliente" itemLabel="#{cliente.nome}" />
</p:selectOneMenu>
@Named @ApplicationScoped public class ClienteConversor implements Converter, Serializable {PessoaConverte
package org.salomao.conversor;
import java.io.Serializable;
import javax.enterprise.context.ApplicationScoped;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import javax.inject.Named;
import org.salomao.model.cliente;
@Named
@ApplicationScoped
public class ClienteConversor implements Converter, Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
public ClienteConversor() {
// TODO Auto-generated constructor stub
}
public Object getAsObject(FacesContext fc, UIComponent uic, String value) {
if (value != null && value.trim().length() > 0) {
try {
return new ClienteDao().findById(Integer.valueOf(value));
} catch (Exception e) {
System.out.println(e.getMessage());
throw new ConverterException(
new FacesMessage(FacesMessage.SEVERITY_ERROR, "Conversion Error", "cliente não valida."));
}
} else {
return null;
}
}
public String getAsString(FacesContext fc, UIComponent uic, Object object) {
if (object != null) {
return ((Cliente) object).getId();
} else {
return null;
}
}
}
}