Galera, estou com uma duvida…
Estou exibindo em uma tabela os dados do meu cliente (que por enquanto só tem nome), queria selecionar essa linha por um botão e colocar aqueles dados em um modal…
Porem não estou conseguindo trazer no modal os dados… ja tentei um monte de coisas e nada…
Alguem sabe o porque?
Segue meu fonte:
// MEU BEAN
public class TesteBean {
private String nome;
public String getNome() {return nome;}
public void setNome(String nome) {this.nome = nome;}
}
// CLASSE QUE EXIBE A LISTA E RECUPERA A SELECIONADA
@ManagedBean(name="cadClientes")
public class TesteMB {
private TesteBean bean = new TesteBean();
private TesteBean linhaSelecionada= new TesteBean();
private List<TesteBean> lista = new ArrayList<TesteBean>();
// GET E SET
public TesteBean getBean() {return bean;}
public TesteBean getLinhaSelecionada() {return linhaSelecionada;}
public List<TesteBean> getLista() {return lista;}
public void setLinhaSelecionada(TesteBean linhaSelecionada) {this.linhaSelecionada = linhaSelecionada;}
public void setLista(List<TesteBean> lista) {this.lista = lista;}
public void setBean(TesteBean bean) {this.bean = bean;}
public String listar(){
bean = new TesteBean();
bean.setNome("Thales");
lista.add(bean);
bean = new TesteBean();
bean.setNome("Thatiana");
lista.add(bean);
return "listar";
}
}
// MEU XHTML QUE TEM O BOTAO PARA CHAMAR A CLASSE E LISTAR
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head><title>Titulo</title></h:head>
<h:body>
<h:form prependId="false">
<p:commandButton ajax="false" value="Listar" action="#{cadClientes.listar}"></p:commandButton>
</h:form>
</h:body>
</html>
// MINHA LISTA
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head><title>Titulo</title></h:head>
<h:body>
<h:form prependId="false" id="form">
<p:panel header="Lista de Clientes">
<p:dataTable var="bean" value="#{cadClientes.lista}">
<p:column headerText="Nome">
<h:outputText value="#{bean.nome}"/>
</p:column>
<p:column headerText="Vizualizar">
<p:commandButton update=":form:display" icon="ui-icon-search" value="Ver" oncomplete="clienteDisplay.show()">
<f:setPropertyActionListener target="#{cadClientes.linhaSelecionada}" value="#{bean}"/>
</p:commandButton>
</p:column>
</p:dataTable>
</p:panel>
<p:dialog widgetVar="clienteDisplay" id="modal-cliente" modal="true" resizable="false">
<h:panelGrid id="display">
<h:outputText value="#{cadClientes.linhaSelecionada.nome}"/>
</h:panelGrid>
</p:dialog>
</h:form>
</h:body>
</html>
Alguem sabe o porque?!
vllw =D