Ajuda DataTable Primefaces

15 respostas
diogoprosoft

Galera seguinte estou fazendo um treeTable e na ultima coluna tenho um <p:commandoLink que irá fazer o download do arquivo o porém é que o de acordo com o exemplo do primefaces o cara que chama o método pegando os dados da linha é o <f:setPropertyActionListener só que não entra dentro do método do controller, alguém teria alguma idéia?

15 Respostas

A

cara,

posta seu xhtml e seu ManagedBean, para poder te ajudar

diogoprosoft

Meu xhtml

<p:treeTable value="#{downloadController.root2}" var="document" style="width:50%">  
			<f:facet name="header">  
    	        Download de Arquivos  
        	</f:facet>  
        	
	        <p:column>  
	            <f:facet name="header">  
	                Nome  
	            </f:facet>  
	            <h:outputText value="#{document.nome}" style="#{document.estilo}"/>  
	        </p:column>
	        
	        <p:column>  
	            <f:facet name="header">  
	                Tamanho  
	            </f:facet>  
	            <h:outputText value="#{document.tamanho}" />  
	        </p:column>

	        <p:column>  
	            <f:facet name="header">  
	                Tipo  
	            </f:facet>  
	            <h:outputText value="#{document.tipo}" />  
	        </p:column>
	        <p:column>
				<p:commandLink update="documentPanel" oncomplete="documentDialog.show()" title="View Detail">  
                	<h:graphicImage url="#{document.icone}"/>   
                	<f:setPropertyActionListener value="#{document}"   
                    	target="#{downloadController.selectedDocument}" />  
            </p:commandLink>
	        </p:column>  
        </p:treeTable>
        
        <p:dialog header="Document Detail" fixedCenter="true" effect="FADE" widgetVar="documentDialog">  
      
        <p:outputPanel id="documentPanel">  
            <h:panelGrid  columns="2" cellpadding="5">  
                <h:outputLabel for="name" value="Name: " />  
                <h:outputText id="name" style="font-weight:bold"  
                    value="#{downloadController.selectedDocument.nome}"  />  
                  
                <h:outputLabel for="size" value="Size: " />  
                <h:outputText id="size" style="font-weight:bold"   
                    value="#{downloadController.selectedDocument.tamanho}"  />  
                  
                <h:outputLabel for="type" value="Type " />  
                <h:outputText id="type" style="font-weight:bold"  
                    value="#{downloadController.selectedDocument.tipo}"  />  
            </h:panelGrid>  
        </p:outputPanel>  
    </p:dialog>

Esse teste com o dialog que estou fazendo é para representar o exemplo do site.!!!

ManagedBean

@ManagedBean
@RequestScoped
public class DownloadController {

	private TreeNode root2;
	private ArquivoBean selectedDocument;

        @PostConstruct
        public void init(){               
                 //montagem do tree
        }

        gets e sets
A

cara,

coloque a opcao immediate=true no commandlink e ve se funciona

t+

diogoprosoft

Pior que não funfou, parece que o commandLink por estar dentro do dataTable não consegue acessar o managedBean

A

cara,

faz um teste com commandButton, pq tenho um projeto aqui e funciona perfeito.
teste sem h:graphicImage, para tirar a duvida

t+

diogoprosoft

Percebi uma coisa, retirei o h:graphicImage e testei colocando o styleClass=“ui-icon ui-icon-search” como está no site e vi que ele só pega os valores que estão no primeiro elemento root nos demais nodes ele não pega!!! Estamos perto o que pode ser será?

A

entao diogo,

ta acontecendo o que eu estava achando, vc nao ta atribuindo uma imagem ao seu link, essa imagem ta ficando em cima do link, por isso que não esta funcionando, coloca essa sua imagem por CSS.

t+

diogoprosoft

sim quanto à isso blz, o maior problema está em pegar o valor da linha entende, pois nesse último teste que fiz ele está pegando o valor da linha mais somente no node0 os outros nodes abertos por ele não funciona, ele não pega os valores…

A

posta seu codigo desta pagina todo, so para eu conferir uma coisa.

t+

diogoprosoft

Ta na mão

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//Dp:column XHTML 1.0 Strict//BR"
	"http://www.w3.org/TR/xhtml1/Dp:column/xhtml1-strict.dp:column">
<html xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets" lang="pt-br">
<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
		lang="pt-br" />
	<title>Documenta&ccedil;&otilde;es</title>
	<link href="css/documentacao.css" rel="stylesheet" type="text/css"></link>
</h:head>
<h:body>
<f:view>
	<h:form prependId="false" id="frmDownload2">
		<p:growl id="messages2" showDetail="true" />
		<br />
		<br />
		<h:panelGrid>
			<p:graphicImage value="imagens/tituloDownload.png"
				id="tituloDownload2" />
		</h:panelGrid>
		
		<p:treeTable value="#{downloadController.root2}" var="document" style="width:50%">  
			<f:facet name="header">  
    	        Download de Arquivos  
        	</f:facet>  
        	
	        <p:column>  
	            <f:facet name="header">  
	                Nome  
	            </f:facet>  
	            <h:outputText value="#{document.nome}" style="#{document.estilo}"/>  
	        </p:column>
	        
	        <p:column>  
	            <f:facet name="header">  
	                Tamanho  
	            </f:facet>  
	            <h:outputText value="#{document.tamanho}" />  
	        </p:column>

	        <p:column>  
	            <f:facet name="header">  
	                Tipo  
	            </f:facet>  
	            <h:outputText value="#{document.tipo}" />  
	        </p:column>
	        <p:column>
				<p:commandLink update="documentPanel" oncomplete="documentDialog.show()" title="View Detail" styleClass="ui-icon ui-icon-search">  
                	   
                	<f:setPropertyActionListener value="#{document}"    
                    	target="#{downloadController.selectedDocument}" />  
            </p:commandLink>
	        </p:column>  
        </p:treeTable>
        
        <p:dialog header="Document Detail" fixedCenter="true" effect="FADE" widgetVar="documentDialog">  
      
        <p:outputPanel id="documentPanel">  
            <h:panelGrid  columns="2" cellpadding="5">  
                <h:outputLabel for="name" value="Name: " />  
                <h:outputText id="name" style="font-weight:bold"  
                    value="#{downloadController.selectedDocument.nome}"  />  
                  
                <h:outputLabel for="size" value="Size: " />  
                <h:outputText id="size" style="font-weight:bold"   
                    value="#{downloadController.selectedDocument.tamanho}"  />  
                  
                <h:outputLabel for="type" value="Type " />  
                <h:outputText id="type" style="font-weight:bold"  
                    value="#{downloadController.selectedDocument.tipo}"  />  
            </h:panelGrid>  
        </p:outputPanel>  
    </p:dialog>  
	</h:form>
<f:view>
</h:body>

</html>
A

é cara, estranho

vc testou colocar a opção immediate=true e tenta tbm com commandButton para ver se funciona.

t+

Polverini

usa no commandLink mesmo

process="@this"
diogoprosoft

Pois é testei sim colocando o immediate e o commandButton, sinceramente não sei o que pode estar acontecendo

diogoprosoft

Colocando o process não funciou nada

A

estranhissimoooo,

minha ultima tentativa… rsrs

faz o seguinte,

<p:commandLink actionListener="#{SEUBEAN.testar(#{document})}" immediate=true/>

crie o metodo testar no seu Bean com parametro um ArquivoBean.

t+

Criado 20 de outubro de 2011
Ultima resposta 20 de out. de 2011
Respostas 15
Participantes 3