Error while listing data in Primefaces Dialog

Asked

Viewed 63 times

1

By clicking on comandButonn this being loaded the last video from the list in the dialog, however in datatable works properly when displayed by the component media. I want to make it easy for the user as follows:

When the user clicks the button abrir the dialog, display the record video X within the dialog and click on the second button to open the video Y. I think it’s a simple thing, but I’m not getting it set up. I’m finding it strange because only shows the last video (It seems that is not updating the painel in the comandButonn. Tentative update=":mensagem :formListagem:tabela formVideo:painelVideo").

Follow some excerpts from the code:

Datatable (Primefaces):

                    <p:commandButton value="Assistir"
                        oncomplete="PF('video').show();"
                        actionListener="#{logicaAlgoritmoBean.selecionarVideo}"
                        update=":mensagem :formListagem:tabela formVideo:painelVideo" >
                        <f:attribute name="videoSelecionado" value="#{logicaAlgoritmo}" />
                    </p:commandButton>

                    <p:dialog header="Vídeo Aula" widgetVar="video"                         
                        position="top" 
                        draggable="true" resizable="true" modal="true">                         
                        <h:form id="formVideo"> 
                            <h:panelGrid id="painelVideo">                      

                                <p:outputLabel id="nomeCurso" maxlength="600" size="40"
                                value="#{logicaAlgoritmoBean.logicaAlgoritmo.curso.nomeCurso}" />

                                <p:outputLabel id="descricao" maxlength="600" size="40"
                                value="#{logicaAlgoritmoBean.logicaAlgoritmo.descricao}" />

                                <p:media cache="false" id="videos"
                                    value="http://localhost:8080/logica/#{logicaAlgoritmo.codigo}.wmv" 
                                    width="910px" 
                                    height="450px" player="windows">    
                                    <f:param name="autoPlay" value="true" />
                                    <f:param name="autostart" value="true" />                       
                                </p:media>                              

                            </h:panelGrid>
                        </h:form>                                                           
                    </p:dialog>

/Here the average component correctly displays the video of each record./

                    <p:media cache="false" id="videos" value="http://localhost:8080/logica/#{logicaAlgoritmo.codigo}.wmv" width="200" 
                        height="150" player="windows">  
                        <f:param name="autoPlay" value="false" />
                        <f:param name="autostart" value="false" />                      
                    </p:media>
                </p:column> 

Method selectVideo, to show on the console the video that was chosen:

public void selecionarVideo(ActionEvent evento){
        logicaAlgoritmo = (LogicaAlgoritmo) evento.getComponent().getAttributes().get("videoSelecionado");
        System.out.println("Vídeo selecionado: "+logicaAlgoritmo);

    }

Method to list:

@PostConstruct
    public void listar() {
        try {
            logicaAlgoritmoDAO logicaAlgoritmoDAO = new logicaAlgoritmoDAO();
            logicaAlgoritmos = logicaAlgoritmoDAO.listar();
        } catch (RuntimeException erro) {
            Messages.addGlobalError("Ocorreu um erro ao tentar listar a vídeo aula!");
            erro.printStackTrace();
            Messages.addGlobalError(erro.getMessage());
        }
    }
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.