Pessoal tenho um selectOneMenu que não passa o valor para o bean,alguem pode me ajudar
veja meu código
cadastroServidorLocal.xhml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Cadastro de Servidores Locais</title>
</h:head>
<h:body>
<h:form id="frmGridServidorLocal">
<p:growl id="menssagensServidorLocal"
life="3000"/>
<p:dataTable widgetVar="dtServidoresLocais"
var="servidorLocal"
value="#{mbServidorLocal.servidoresLocais}"
paginator="true"
rows="5"
selection="#{mbServidorLocal.servidorLocal}"
selectionMode="single"
onRowSelectComplete="dlgServidorLocal.show()"
emptyMessage="Não existe Servidor Local Cadastrado"
style="width:100%"
update="frmCadastroServidorLocal">
<p:column sortBy="#{servidorLocal.id}"
filterBy="#{servidorLocal.id}"
style="width:10%">
<f:facet name="header">
<h:outputText value="Id" />
</f:facet>
<h:outputText value="#{servidorLocal.id}"/>
</p:column>
<p:column sortBy="#{servidorLocal.nome}"
filterBy="#{servidorLocal.nome}">
<f:facet name="header">
<h:outputText value="Servidor" />
</f:facet>
<h:outputText value="#{servidorLocal.nome}"/>
</p:column>
<p:column sortBy="#{servidorLocal.cliente.nome}"
filterBy="#{servidorLocal.cliente.nome}">
<f:facet name="header">
<h:outputText value="Cliente" />
</f:facet>
<h:outputText value="#{servidorLocal.cliente.nome}"/>
</p:column>
<p:column sortBy="#{servidorLocal.ip}"
filterBy="#{servidorLocal.ip}">
<f:facet name="header">
<h:outputText value="IP" />
</f:facet>
<h:outputText value="#{servidorLocal.ip}"/>
</p:column>
<p:column sortBy="#{servidorLocal.porta}"
filterBy="#{servidorLocal.porta}">
<f:facet name="header">
<h:outputText value="Porta" />
</f:facet>
<h:outputText value="#{servidorLocal.porta}"/>
</p:column>
</p:dataTable>
<p:panel style="width:99.2%">
<p:commandLink title="Novo"
action="#{mbServidorLocal.incluir}"
oncomplete="dlgServidorLocal.show();"
update="frmCadastroServidorOrigem">
<p:graphicImage url="/imagens/novo.jpg"
style="border:0"/>
</p:commandLink>
<h:commandLink title="Apagar"
action="#{mbServidorLocal.apagar}"
style="margin-left:20px"
update="frmGridServidorLocal">
<h:graphicImage url="/imagens/apagar.jpg"
style="border:0"/>
</h:commandLink>
<p:commandLink title="Voltar"
action="#{mbServidorLocal.voltar}"
ajax="false"
style="margin-left:20px">
<h:graphicImage url="/imagens/voltar.jpg"
style="border:0"/>
</p:commandLink>
</p:panel>
</h:form>
<p:dialog id="dlgServidorLocal"
widgetVar="dlgServidorLocal"
header="Servidor Local"
width="500">
<h:form id="frmCadastroServidorOrigem">
<h:panelGrid columns="2">
<h:outputLabel value="Id"
for="itxId"
rendered="#{!empty mbServidorLocal.servidorLocal.id}" />
<h:inputText id="itxId"
value="#{mbServidorLocal.servidorLocal.id}"
disabled="true"
rendered="#{!empty mbServidorLocal.servidorLocal.id}"/>
<h:outputLabel value="Servidor"
for="itxNomeServidor"/>
<h:inputText id="itxNomeServidor"
value="#{mbServidorLocal.servidorLocal.nome}"
size="35"
required="true"
requiredMessage="Informe o nome"/>
<h:outputLabel value="IP"
for="itxIP"/>
<h:inputText id="itxIP"
value="#{mbServidorLocal.servidorLocal.ip}"
size="35"
required="true"
requiredMessage="Informe o IP "/>
<h:outputLabel value="Porta"
for="itxPorta"/>
<h:inputText id="itxPorta"
value="#{mbServidorLocal.servidorLocal.porta}"
size="35"
required="true"
requiredMessage="Informe a Porta"/>
<h:outputLabel value="Cliente"
for="somCliente" />
<h:selectOneMenu id="somCliente"
value="#{mbServidorLocal.servidorLocal.cliente.id}"
required="true"
requiredMessage="Informe o Cliente " >
<f:selectItems value="#{mbServidorLocal.clientes}"
var="cliente"
itemLabel="#{cliente.nome}"
itemValue="#{cliente.id}"/>
</h:selectOneMenu>
</h:panelGrid>
<h:panelGrid columns="3">
<h:commandLink title="Gravar"
action="#{mbServidorLocal.gravar}"
rendered="#{empty mbServidorLocal.servidorLocal.id}"
update="frmGridServidorLocal">
<p:graphicImage url="/imagens/gravar_servidor.jpg"
style="border:0"/>
</h:commandLink>
<p:commandLink title="Alterar"
actionListener="#{mbServidorLocal.alterar}"
rendered="#{!empty mbServidorLocal.servidorLocal.id}"
update="frmGridServidorLocal"
oncomplete="dlgServidorLocal.hide();">
<p:graphicImage url="/imagens/gravar_servidor.jpg"
style="border:0"/>
</p:commandLink>
</h:panelGrid>
</h:form>
</p:dialog>
</h:body>
</html>
MBServidorLocal
package controladores;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ActionEvent;
import negocios.ServidorOrigemBO;
import entidades.Cliente;
import entidades.ServidorLocal;
@ManagedBean(name="mbServidorLocal")
@ViewScoped
public class MBServidorLocal implements Serializable{
private static final long serialVersionUID = 4718957167100835066L;
private ServidorOrigemBO servidorOrigemBO;
private ServidorLocal servidorLocal;
private List<ServidorLocal> servidoresLocais;
private List<Cliente> clientes;
public MBServidorLocal(){
this.setServidorOrigemBO(new ServidorOrigemBO());
this.setServidorLocal(new ServidorLocal());
this.setServidoresLocais(this.listar());
this.setClientes(this.listarClientes());
}
public ServidorOrigemBO getServidorOrigemBO() {
return servidorOrigemBO;
}
public void setServidorOrigemBO(ServidorOrigemBO servidorOrigemBO) {
this.servidorOrigemBO = servidorOrigemBO;
}
public ServidorLocal getServidorLocal() {
return servidorLocal;
}
public void setServidorLocal(ServidorLocal servidorLocal) {
this.servidorLocal = servidorLocal;
}
public List<ServidorLocal> getServidoresLocais() {
return servidoresLocais;
}
public void setServidoresLocais(List<ServidorLocal> servidoresLocais) {
this.servidoresLocais = servidoresLocais;
}
public List<Cliente> getClientes() {
return clientes;
}
public void setClientes(List<Cliente> clientes) {
this.clientes = clientes;
}
public void incluir(){
System.out.println("incluindo");
this.setServidorLocal(new ServidorLocal());
}
public void gravar() {
try {
this.getServidorOrigemBO().gravar(this.getServidorLocal());
this.getServidoresLocais().add(this.getServidorLocal());
this.setServidorLocal(new ServidorLocal());
System.out.println("Cliente" + this.servidorLocal.getCliente().getId()); // imprimi null
for(ServidorLocal sl : this.getServidoresLocais()){
System.out.println(sl.getCliente().getNome()); // imprimi null
}
JSFUtil.enviarMenssagemSucesso("Servidor Local gravado com sucesso");
} catch (Exception e) {
JSFUtil.enviarMenssagemErro("Erro ao gravar" + " " + e.getMessage());
}
}
public void alterar(ActionEvent evento) {
try {
Integer indice = this.getServidoresLocais().indexOf(this.getServidorLocal());
this.getServidorOrigemBO().alterar(this.getServidorLocal());
this.getServidoresLocais().remove(this.getServidorLocal());
this.getServidoresLocais().add(indice, this.getServidorLocal());
JSFUtil.enviarMenssagemSucesso("Servidor Local alterado com sucesso");
} catch (Exception e) {
JSFUtil.enviarMenssagemErro("Erro ao alterar" + " "
+ e.getMessage());
}
}
public void apagar() {
if(this.getServidorLocal() == null || (this.getServidorLocal() != null && this.getServidorLocal().getId() == null) ) {
JSFUtil.enviarMenssagemAtencao("Selecione um Servidor Local na grid");
}else {
try {
this.getServidorOrigemBO().apagar(this.getServidorLocal());
this.getServidoresLocais().remove(this.getServidorLocal());
JSFUtil.enviarMenssagemSucesso("Servidor Local apagado com sucesso");
} catch (Exception e) {
JSFUtil.enviarMenssagemErro("Erro ao apagar" + " " + e.getMessage());
}
}
}
public List<ServidorLocal> listar() {
List<ServidorLocal> servidoresLocal = new ArrayList<ServidorLocal>();
try {
servidoresLocal = (List<ServidorLocal>) this.getServidorOrigemBO().listar();
} catch (Exception e) {
JSFUtil.enviarMenssagemErro("Erro ao Listar Servidores Locais" + " " + e.getMessage());
}
return servidoresLocal;
}
public List<Cliente> listarClientes() {
List<Cliente> clientes = new ArrayList<Cliente>();
try {
clientes = this.getServidorOrigemBO().listarClientes();
} catch (Exception e) {
JSFUtil.enviarMenssagemErro("Erro ao Listar Clientes" + " " + e.getMessage());
}
return clientes;
}
public String voltar() {
return "index";
}
}