datatableRowSelectionByColumn primefaces

e ai gente.
estou querendo fazer que nem o ShowCase mostra http://www.primefaces.org/showcase/ui/datatableRowSelectionByColumn.jsf , mostrar detalhes em uma dialog
mas não funciona, só mostra os textos, e não o conteúdo, meus códigos:
DocumentoMB:


package managedBeans;

@ManagedBean(name = "documentoMB")
@SessionScoped
public class DocumentoMB implements Serializable {
    
    private Documento documento;
    @EJB
    private DocumentoFacade documentoFacade;
         
    public DocumentoMB() {
    }

    public Documento getDocumento() {
        return documento;
    }

    public void setDocumento(Documento documento) {
        this.documento = documento;
    }
    

    public Documento getSelected() {
        if (documento == null) {
            documento = new Documento();
            selectedItemIndex = -1;
        }
        return documento;
    }

    private DocumentoFacade getFacade() {
        return documentoFacade;
    }

}

claro que tem mais coisas

e minha tela:


   <p:dataTable value="#{documentoMB.items}" var="item" id="tabela">                  
		  <p:column style="width:40px"> 
                        <f:facet name="header">
                            <h:outputText value="Detalhes"/>
                        </f:facet>
                            <p:commandButton id="selectButton" oncomplete="itemDialog.show()" icon="ui-icon-search" title="View">  
                                <f:setPropertyActionListener value="#{item}" target="#{documentoMB.documento}"/>  
                            </p:commandButton>                          
                    </p:column> 
                </p:dataTable>

                <p:dialog header="Detalhes do Documento" widgetVar="itemDialog" resizable="false" id="carDlg"  
                          showEffect="fade" modal="true">  

                    <h:panelGrid id="display" columns="2" cellpadding="4" style="margin:0 auto;">  
                        <h:outputText value="#{bundle.DocumentoLabel_ano}"/>
                        <h:outputText value="#{documentoMB.selected.ano}" title="#{bundle.DocumentoTitle_ano}"/>
                        <h:outputText value="#{bundle.DocumentoLabel_titulo}"/>
                        <h:outputText value="#{documentoMB.selected.titulo}" title="#{bundle.DocumentoTitle_titulo}"/>
                        <h:outputText value="#{bundle.DocumentoLabel_instituicao}"/>
                        <h:outputText value="#{documentoMB.selected.instituicao}" title="#{bundle.DocumentoTitle_instituicao}"/>
                        <h:outputText value="#{bundle.DocumentoLabel_curso}"/>
                        <h:outputText value="#{documentoMB.selected.curso}" title="#{bundle.DocumentoTitle_curso}"/>
                        
                    </h:panelGrid>  

                </p:dialog>  

sempre que eu clico no botão detalhes não mostra nada no dialog, e de vez uma vez eu consegui, porém mostrava os detalhes só de um, caso escolhe-se outro, ele mostrava o mesmo selecionado por primeiro.
acho que deu para entender

Cara, no dialog vc usa o objeto #{documentoMB.selected.ano}

mas na hora passar o valor vc usa: target="#{documentoMB.documento}"

Nao seria isso nao?

Eita, ignora oq eu falei acima.

Esse povo ta dentro de um form?

Faltou você dar update nesse form, ou entao, coloca um form no dialog e da update nesse dialog.

cara quando eu faço isso:

[code]
<p:column style=“width:40px”>
<f:facet name=“header”>
<h:outputText value=“Detalhes” />
</f:facet>

                    <h:panelGrid columns="3" styleClass="actions" cellpadding="2">  
                        <p:commandButton id="selectButton"  oncomplete="itemDialog.show()" icon="ui-icon-search" title="View">  
                            <f:setPropertyActionListener value="#{item}" target="#{documentoMB.documento}" />  
                        </p:commandButton>  
                    </h:panelGrid> 

</p:column>[/code]
ele mostra o dialog mas não mostra os detalhes, só os textos.

quando eu faço isso:

 <p:commandButton id="selectButton" update=":form:display" oncomplete="itemDialog.show()" icon="ui-icon-search" title="View">

desaparece o botão

como esta minha tela na integra:


<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui">

    <ui:define name="subtitulo">
        <h:outputText value="#{bundle.ListDocumentoTitle}"/>
    </ui:define>

    <ui:define name="principal">
        <h:form styleClass="jsfcrud_list_form">
            <div align="left">
                <h:commandButton value="#{bundle.CreateDocumentoTitle}" action="adicionar"/>
            </div>
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:outputText escape="false" value="#{bundle.ListDocumentoEmpty}" rendered="#{documentoMB.items.rowCount == 0}"/>
            <h:panelGroup rendered="#{documentoMB.items.rowCount > 0}">
                <h:outputText value="#{documentoMB.pagination.pageFirstItem + 1}..#{documentoMB.pagination.pageLastItem + 1}/#{documentoMB.pagination.itemsCount}"/>&nbsp;
                <h:commandLink action="#{documentoMB.previous}" value="#{bundle.Previous} #{documentoMB.pagination.pageSize}" rendered="#{documentoMB.pagination.hasPreviousPage}"/>&nbsp;
                <h:commandLink action="#{documentoMB.next}" value="#{bundle.Next} #{documentoMB.pagination.pageSize}" rendered="#{documentoMB.pagination.hasNextPage}"/>&nbsp;
                <p:dataTable value="#{documentoMB.items}" var="item" id="tabela"
                             rowStyleClass="#{empty rowIx or rowIx mod 2 ne 0 ? 'even-row' : 'odd-row'}" rowIndexVar="rowIx" 
                             paginator="true" rows="10"  
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                             rowsPerPageTemplate="10,20"
                             styleClass="tabela">
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.DocumentoTitle_titulo}"/>
                        </f:facet>
                        <h:outputText value="#{item.titulo}"/>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.DocumentoTitle_tipo}"/>
                        </f:facet>
                        <h:outputText value="#{item.tipo}"/>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{bundle.DocumentoTitle_ano}"/>
                        </f:facet>
                        <h:outputText value="#{item.ano}"/>
                    </p:column>

                    <p:column>  
                        <f:facet name="header">  
                            <h:outputText value="Download" />  
                        </f:facet>

                        <h:commandButton image="css/down.png" id="downloadLink" value="Downloads" ajax="false" styleClass="imageClass" > 
                            <p:fileDownload  value="#{documentoMB.getFile(item)}" id="download"></p:fileDownload> 
                        </h:commandButton>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Opções"/>
                        </f:facet>
                        <h:commandLink action="#{documentoMB.prepareView}" value="#{bundle.ViewLink}"/>
                        <h:outputText value=" "/>
                        <h:commandLink action="#{documentoMB.prepareEdit}" value="#{bundle.EditLink}"/>
                        <h:outputText value=" "/>
                        <h:commandLink value="#{bundle.DestroyLink}" action="#{documentoMB.destroyAndView}"/>

                    </p:column>

                    <p:column style="width:40px"> 
                        <f:facet name="header">  
                            <h:outputText value="Detalhes" />  
                        </f:facet>
                        
                        <h:panelGrid columns="3" styleClass="actions" cellpadding="2">  
                            <p:commandButton id="selectButton"  oncomplete="itemDialog.show()" icon="ui-icon-search" title="View">  
                                <f:setPropertyActionListener value="#{item}" target="#{documentoMB.documento}" />  
                            </p:commandButton>  
                        </h:panelGrid> 
                        
                    </p:column> 
                </p:dataTable>

                <p:dialog header="Detalhes do Documento" widgetVar="itemDialog" resizable="false" id="carDlg"  
                          showEffect="fade" modal="true">  

                    <h:panelGrid id="display" columns="2" cellpadding="4" style="margin:0 auto;">  
                        <h:outputText value="#{bundle.DocumentoLabel_resumo}"/>
                        <h:outputText value="#{documentoMB.selected.resumo}" title="#{bundle.DocumentoTitle_resumo}"/>
                        <h:outputText value="#{bundle.DocumentoLabel_tipo}"/>
                        <h:outputText value="#{documentoMB.selected.tipo}" title="#{bundle.DocumentoTitle_tipo}"/>
                        <h:outputText value="#{bundle.DocumentoLabel_ano}"/>
                        <h:outputText value="#{documentoMB.selected.ano}" title="#{bundle.DocumentoTitle_ano}"/>
                        <h:outputText value="#{bundle.DocumentoLabel_titulo}"/>
                        <h:outputText value="#{documentoMB.selected.titulo}" title="#{bundle.DocumentoTitle_titulo}"/>
                        <h:outputText value="#{bundle.DocumentoLabel_caminho}"/>
                        <h:outputText value="#{documentoMB.selected.caminho}" title="#{bundle.DocumentoTitle_caminho}"/>
                        <h:outputText value="#{bundle.DocumentoLabel_instituicao}"/>
                        <h:outputText value="#{documentoMB.selected.instituicao}" title="#{bundle.DocumentoTitle_instituicao}"/>
                        <h:outputText value="#{bundle.DocumentoLabel_curso}"/>
                        <h:outputText value="#{documentoMB.selected.curso}" title="#{bundle.DocumentoTitle_curso}"/>
                        <h:outputText value="#{bundle.DocumentoLabel_area}"/>
                        <h:outputText value="#{documentoMB.selected.area}" title="#{bundle.DocumentoTitle_area}"/>
                    </h:panelGrid>  

                </p:dialog>  

            </h:panelGroup>
        </h:form>
    </ui:define>

</ui:composition>

e o managedbean:


package managedBeans;

import facade.DocumentoFacade;
import java.io.*;
import java.util.ResourceBundle;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import javax.faces.model.SelectItem;
import managedBeans.util.JsfUtil;
import managedBeans.util.PaginationHelper;
import modelo.Documento;
import org.primefaces.event.FileUploadEvent;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import org.primefaces.model.UploadedFile;

@ManagedBean(name = "documentoMB")
@SessionScoped
public class DocumentoMB implements Serializable {
    
    private Documento documento;
    private DataModel items = null;
    @EJB
    private facade.DocumentoFacade documentoFacade;
    private PaginationHelper pagination;
    private int selectedItemIndex;
    
    private StreamedContent file;

    public void setFile(StreamedContent file) {
        this.file = file;
    }
    
    public StreamedContent getFile(Documento documento) throws FileNotFoundException {
        String arquivo = documento.getTitulo();
        String caminho = documento.getCaminho();
        FileInputStream stream = new FileInputStream(caminho);
        file = new DefaultStreamedContent(stream, caminho, arquivo);
        return file;
    }
    
    public DocumentoMB() {
    }

    public Documento getDocumento() {
        return documento;
    }

    public void setDocumento(Documento documento) {
        this.documento = documento;
    }
    

    public Documento getSelected() {
        if (documento == null) {
            documento = new Documento();
            selectedItemIndex = -1;
        }
        return documento;
    }

    private DocumentoFacade getFacade() {
        return documentoFacade;
    }

    public PaginationHelper getPagination() {
        if (pagination == null) {
            pagination = new PaginationHelper(10) {

                @Override
                public int getItemsCount() {
                    return getFacade().count();
                }

                @Override
                public DataModel createPageDataModel() {
                    return new ListDataModel(getFacade().findRange(new int[]{getPageFirstItem(), getPageFirstItem() + getPageSize()}));
                }
            };
        }
        return pagination;
    }

    public String prepareList() {
        recreateModel();
        return "lista";
    }

    public String prepareView() {
        documento = (Documento) getItems().getRowData();
        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
        return "detalhes";
    }

    public String prepareCreate() {
        documento = new Documento();
        selectedItemIndex = -1;
        return "adicionar";
    }

    public String create() {
        try {
            getFacade().create(documento);
            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("DocumentoCreated"));
            return prepareCreate();
        } catch (Exception e) {
            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
            return null;
        }
    }
    
    public void fileUploadAction(FileUploadEvent event) throws IOException {
        try {
            UploadedFile arq = event.getFile();
            InputStream in = new BufferedInputStream(arq.getInputstream());             
            File file = new File("/home/jaisson/upload/" + arq.getFileName());
            documento.setCaminho(file.getAbsolutePath());
            FileOutputStream fout = new FileOutputStream(file);
            while (in.available() != 0) {
                fout.write(in.read());
            }

            fout.close();
            FacesMessage msg = new FacesMessage("O Arquivo ", file.getName() + " salvo.");
            FacesContext.getCurrentInstance().addMessage("msgUpdate", msg);
        } catch (Exception ex) {
            System.out.println("erro no upload "+ex.getMessage());
        }
    }

    public String prepareEdit() {
        documento = (Documento) getItems().getRowData();
        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
        return "editar";
    }

    public String update() {
        try {
            getFacade().edit(documento);
            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("DocumentoUpdated"));
            return "detalhes";
        } catch (Exception e) {
            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
            return null;
        }
    }

    public String destroy() {
        documento = (Documento) getItems().getRowData();
        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
        performDestroy();
        recreatePagination();
        recreateModel();
        return "lista";
    }

    public String destroyAndView() {
        performDestroy();
        recreateModel();
        updateCurrentItem();
        if (selectedItemIndex >= 0) {
            return "detalhes";
        } else {
            // all items were removed - go back to list
            recreateModel();
            return "lista";
        }
    }

    private void performDestroy() {
        try {
            getFacade().remove(documento);
            JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("DocumentoDeleted"));
        } catch (Exception e) {
            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
        }
    }

    private void updateCurrentItem() {
        int count = getFacade().count();
        if (selectedItemIndex >= count) {
            // selected index cannot be bigger than number of items:
            selectedItemIndex = count - 1;
            // go to previous page if last page disappeared:
            if (pagination.getPageFirstItem() >= count) {
                pagination.previousPage();
            }
        }
        if (selectedItemIndex >= 0) {
            documento = getFacade().findRange(new int[]{selectedItemIndex, selectedItemIndex + 1}).get(0);
        }
    }

    public DataModel getItems() {
        if (items == null) {
            items = getPagination().createPageDataModel();
        }
        return items;
    }

    private void recreateModel() {
        items = null;
    }

    private void recreatePagination() {
        pagination = null;
    }

    public String next() {
        getPagination().nextPage();
        recreateModel();
        return "lista";
    }

    public String previous() {
        getPagination().previousPage();
        recreateModel();
        return "lista";
    }

    public SelectItem[] getItemsAvailableSelectMany() {
        return JsfUtil.getSelectItems(documentoFacade.findAll(), false);
    }

    public SelectItem[] getItemsAvailableSelectOne() {
        return JsfUtil.getSelectItems(documentoFacade.findAll(), true);
    }

    @FacesConverter(forClass = Documento.class)
    public static class DocumentoControllerConverter implements Converter {

        public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
            if (value == null || value.length() == 0) {
                return null;
            }
            DocumentoMB controller = (DocumentoMB) facesContext.getApplication().getELResolver().
                    getValue(facesContext.getELContext(), null, "documentoController");
            return controller.documentoFacade.find(getKey(value));
        }

        java.lang.Integer getKey(String value) {
            java.lang.Integer key;
            key = Integer.valueOf(value);
            return key;
        }

        String getStringKey(java.lang.Integer value) {
            StringBuffer sb = new StringBuffer();
            sb.append(value);
            return sb.toString();
        }

        public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
            if (object == null) {
                return null;
            }
            if (object instanceof Documento) {
                Documento o = (Documento) object;
                return getStringKey(o.getCodigo());
            } else {
                throw new IllegalArgumentException("object " + object + " is of type " + object.getClass().getName() + "; expected type: " + DocumentoMB.class.getName());
            }
        }
    }
}

mas olha só que estranho, quando dei F5 mostrou os dados, mas quando escolhi outro, mostrou o anterior, ai executei de novo a página e parou de funcionar, :shock:
acho que o cara esta brincando comigo :twisted: