Primefaces dataTable

1 resposta
esqueleto

Pessoal quando eu coloco a pesquisar em dois forms funciona mas quando coloco tudo em so da erro. O valor do inputText não e passado. Alguem pode me explicar o porque? Segue abaixo o meu xhtml.
Pessoal ja estou beirando o desespero.

<html xmlns="http://www.w3c.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>

<h:body>
	<h:form id="formPesquisaCliente" prependId="false">
		<h:panelGrid columns="3" id="panelPrincipal">
			<h:outputLabel value="Nome:" styleClass="icoObrigatorio" />
			<p:inputText value="#{pesquisaClienteBean.cliente.nome}"
				required="true" id="desc" size="50" maxlength="255" />
			<p:message for="desc" />
			
			<h:outputLabel value="Ciente:" styleClass="icoObrigatorio" />
			<p:inputText value="#{pesquisaClienteBean.cliente.nome}"
				required="true" id="cliente" size="50" maxlength="255" />
			<p:message for="cliente" />
		</h:panelGrid>

		<p:commandButton value="..." ajax="false"
			action="${pesquisaClienteBean.pesquisar}" />
	..se eu inserio o outro form aqui funciona.. pq??? ai eu não consigo atualizar os outros campos a partir de uma seleção na tabela abaixo.
		<p:dataTable paginator="true" rows="5" var="c" lazy="true"
			value="#{pesquisaClienteBean.model}">
			<p:column headerText="Nome">
				<p:commandLink style="padding:5px !important;" onclick="alert('tss')" 
							action="#{pesquisaClienteBean.adicionarCliente}">
					<h:outputLabel value="#{c.nome}" />
				</p:commandLink>
			</p:column>
			<p:column headerText="Email" >
				<h:outputLabel value="#{c.email}" />
			</p:column>
			<p:column headerText="CPF" >
				<h:outputLabel value="#{c.cpfCliente}" />
			</p:column>
			<p:column headerText="Endereço">
				<h:outputLabel value="#{c.endereco}" />
			</p:column>
			<p:column headerText="Data Nasc.">
				<h:outputLabel value="#{c.dataNascimento}" />
			</p:column>
		</p:dataTable>

	</h:form>

</h:body>
</html>

bean

package br.com.femna.bean;

import java.util.Map;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;

import org.primefaces.model.LazyDataModel;



import br.com.femna.datamodel.LazyClienteDataModel;
import br.com.femna.entidade.Cliente;

@ManagedBean(name="pesquisaClienteBean")
@ViewScoped
public class PesquisaClienteBean {
	
	private Cliente cliente;
	private LazyDataModel<Cliente> model;


	public PesquisaClienteBean(){
	}
	
	public LazyDataModel<Cliente> getModel() {
		FacesContext fc = FacesContext.getCurrentInstance(); 
		 Map<String,String> params = fc.getExternalContext().getRequestParameterMap();
		 System.out.println(cliente.getNome());
		model = new LazyClienteDataModel(cliente);
		return model;
	}
	
	public String adicionarCliente(){
		
		return "success";
	}

	
	public String pesquisar(){
		System.out.println("o eu aqui...>>> " + cliente.getNome());
		return "success";
	}

	public Cliente getCliente() {
		if(cliente == null){
			cliente = new Cliente();
		}
		return cliente;
	}

	public void setCliente(Cliente cliente) {
		this.cliente = cliente;
	}
}

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>femna</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <filter>
    <filter-name>HibernateFilter</filter-name>
    <filter-class>br.com.femna.util.HibernateSessionRequestFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>HibernateFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  
</web-app>

xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">

<?xml version="1.0" encoding="UTF-8"?>

<faces-config
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">

</faces-config>

1 Resposta

b10machado

cara já passei por isso , não sei a reposta tecnica para isso, mas acredito que seja por que ele precisa esta dentro d um form proprio para as acoes dele como no botoes!! se alguem souber a explicaçao tecnica, tbm gostaria de saber vlw!!

Criado 15 de julho de 2012
Ultima resposta 16 de jul. de 2012
Respostas 1
Participantes 2