<p:dialog> Primefaces Probleme?</p:dialog>

时间:2014-01-06 02:06:44

标签: jsf java-ee primefaces datatable

我为DiplomeBean创建了一个复杂的dataTable,它显示正确 这笔交易是我从列表中选择一行,没有任何事情发生

我想要选择一行,它会向我显示diplome的元素。

我的豆子

package com.beans;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.bo.DiplomeBo;
import com.converter.DiplomeDataModel;
import com.model.Collaborateur;
import com.model.Diplome;

public class DiplomeBean  {

    public Integer idDiplome;
    public String ecole;
    public String typeEcole;
    public String typeDiplome;
    public Integer promotion;
    private Set<Collaborateur> collaborateurs = new HashSet<Collaborateur>(0);

    public Diplome selectedDiplome;

    public Diplome getSelectedDiplome() {
        return selectedDiplome;
    }


    public void setSelectedDiplome(Diplome selectedDiplome) {
        this.selectedDiplome = selectedDiplome;
    }  

    public Integer getIdDiplome() {
        return idDiplome;
    }
    public void setIdDiplome(Integer idDiplome) {
        this.idDiplome = idDiplome;
    }

    private DiplomeBo diplomeBo;

    public String getEcole() {
        return ecole;
    }
    public void setEcole(String ecole) {
        this.ecole = ecole;
    }
    public String getTypeEcole() {
        return typeEcole;
    }
    public void setTypeEcole(String typeEcole) {
        this.typeEcole = typeEcole;
    }
    public Integer getPromotion() {
        return promotion;
    }
    public void setPromotion(Integer promotion) {
        this.promotion = promotion;
    }
    public Set<Collaborateur> getCollaborateurs() {
        return collaborateurs;
    }
    public void setCollaborateurs(Set<Collaborateur> collaborateurs) {
        this.collaborateurs = collaborateurs;
    }
    public void setDiplomeBo(DiplomeBo diplomeBo) {
        this.diplomeBo = diplomeBo;
    }


    public String getTypeDiplome() {
        return typeDiplome;
    }
    public void setTypeDiplome(String typeDiplome) {
        this.typeDiplome = typeDiplome;
    }

    public String AddDiplome(){
        Diplome diplome =new Diplome();
        diplome.setEcole(getEcole());
        diplome.setPromotion(getPromotion());
        diplome.setTypeDiplome(getTypeDiplome());
        diplome.setTypeEcole(getTypeEcole());
        diplomeBo.addDiplome(diplome);
        clearForm();
        return "Ajout Bien Fait !!";
    }

    public List<Diplome> getAllDiplome(){
        return diplomeBo.findAllDiplome();
    }

    private void clearForm(){
        this.setEcole("");
        this.setPromotion(0);
        this.setTypeEcole("Choisir type..");
        this.setTypeEcole("Choisir type..");

    }




}

我的页面

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<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:p="http://primefaces.org/ui">
<h:head></h:head> 

<body> 
<f:view>
<h:outputLink value="Admin/default.xhtml">Go to your app</h:outputLink>

        <h:form>

        <p:dataTable value="#{diplome.getAllDiplome()}"  var="d" paginator="true" rows="10" rowKey="diplome.idDiplome" 
                selection="#{diplome.selectedDiplome}" selectionMode="single"  
                onRowSelectUpdate="display" onRowSelectComplete="diplomeDialog.show()">  

        <f:facet name="header">  
            Diplome Liste  
        </f:facet>  

        <p:column sortBy="#{d.idDiplome}" filterBy="#{d.idDiplome}">  
            <f:facet name="header">  
                <h:outputText value="Model" />  
            </f:facet>  
            <h:outputText value="#{d.idDiplome}" />  
        </p:column>  

        <p:column sortBy="#{d.ecole}" filterBy="#{d.ecole}">  
            <f:facet name="header">  
                <h:outputText value="Ecole" />  
            </f:facet>  
            <h:outputText value="#{d.ecole}" />  
        </p:column>  


    </p:dataTable>  

    <p:dialog  header="Diplome Detail" widgetVar="diplomeDialog" resizable="false"  
              width="200" showEffect="explode" hideEffect="explode">  


            <h:outputText value="id:" />  
            <h:outputText value="#{diplome.selectedDiplome.idDiplome}" />  

            <h:outputText value="Ecole:" />  
            <h:outputText value="#{diplome.selectedDiplome.ecole}" />  



    </p:dialog>  

</h:form>  


</f:view>
</body> 
</html>

谢谢:)

1 个答案:

答案 0 :(得分:0)

或许尝试稍微修改它以更像Primefaces showcase example。例如,尝试这样的事情:

...

<h:form id="form">

    ...

    <p:dataTable value="#{diplome.getAllDiplome()}"  var="d" paginator="true" rows="10"
        rowKey="diplome.idDiplome" selection="#{diplome.selectedDiplome}" selectionMode="single">  
        <p:ajax event="rowSelect" update=":form:display" oncomplete="PF('diplomeDialog').show()" />

        ...

    </p:dataTable>

    ...

    <p:dialog  header="Diplome Detail" widgetVar="diplomeDialog" resizable="false"  
          width="200" showEffect="explode" hideEffect="explode">  
        <h:panelGrid id="display">

           ...

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

</h:form>

...

我现在无法测试,但似乎它应该可以工作,因为它与展示的示例基本相同。