0

我正在使用 primefaces jsf 的数据列表。我只是从 arraylist 填充数据并显示在 datalist 中,还使用对话框进行详细视图,但是选择值对话框的问题没有显示它们。这里是代码 UI 类:

<?xml version="1.0"?>

<f:view xmlns="http://www.w3.org/1999/xhtml"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head />

    <h:body>
        <h:form id="form">
            <p:dataList value="#{tableBean.applicantlist}" var="applicant"
                id="applicants" paginator="true" rows="5"
                paginatorTemplate="{PreviousPageLink} {CurrentPageReport} {NextPageLink} {RowsPerPageDropdown}"
                rowsPerPageTemplate="5,10,15" type="none">


                <f:facet name="header">  
                Applicants 
            </f:facet>


                <h:outputText value="#{applicant.jobtitle}, #{applicant.useremail}"
                    style="margin-left:10px" />

                <p:commandButton icon="ui-icon-search" update=":form:appDetail"
                    oncomplete="appDialog.show()" title="View Detail">
                    <f:setPropertyActionListener value="#{applicant}"
                        target="#{tableBean.selectedApplicant}" />
                </p:commandButton>

            </p:dataList>


            <p:dialog header="Car Detail" widgetVar="appDialog" modal="true"
                showEffect="fade">
                <p:outputPanel id="appDetail" style="text-align:center;"
                    layout="block">



                    <h:panelGrid columns="2" cellpadding="5">
                        <h:outputLabel for="modelNo" value="Model No: " />
                        <h:outputText id="modelNo"
                            value="#{tableBean.selectedApplicant.useremail}" />

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

        </h:form>


    </h:body>
</f:view> 

这是桌豆:

package com.DTO;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;

@ManagedBean
@SessionScoped
public class TableBean implements Serializable {

    private List<InterViewDto> applicantlist;
    private InterViewDto selectedApplicant;

    public List<InterViewDto> getApplicantlist() {
        return applicantlist;
    }

    public void setApplicantlist(List<InterViewDto> applicantlist) {
        this.applicantlist = applicantlist;
    }

    public InterViewDto getSelectedApplicant() {
        return selectedApplicant;
    }

    public void setSelectedApplicant(InterViewDto selectedApplicant) {
        this.selectedApplicant = selectedApplicant;
    }

    public TableBean() {
        getSelectedApplicant();
        applicantlist = new ArrayList<InterViewDto>();
        InterViewDto p1 = new InterViewDto();
        p1.setJobtitle("junaid");
        p1.setUseremail("email@hotmail.com");
        applicantlist.add(p1);

    }

}

Here is DTO Class:

package com.DTO;

import java.sql.SQLException;
import java.util.Date;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;



@ManagedBean
@SessionScoped
public class InterViewDto {

    String useremail,jobtitle;
    Date date;
    public String getUseremail() {
        return useremail;
    }

    public InterViewDto(){

    }
    public void setUseremail(String useremail) {
        this.useremail = useremail;
    }
    public String getJobtitle() {
        return jobtitle;
    }
    public void setJobtitle(String jobtitle) {
        this.jobtitle = jobtitle;
    }
    public Date getDate() {
        return date;
    }
    public void setDate(Date date) {
        this.date = date;
    }





}
4

1 回答 1

0

p:commandButtonp:commandLink如果列表未包含在p:column.

将表中所示的每一项附上p:column

<p:dataList value="#{tableBean.applicantlist}" var="applicant"
                id="applicants" paginator="true" rows="5"
                paginatorTemplate="{PreviousPageLink} {CurrentPageReport} {NextPageLink} {RowsPerPageDropdown}"
                rowsPerPageTemplate="5,10,15" type="none">


              <p:column > 
                <h:outputText value="#{applicant.jobtitle}, #{applicant.useremail}"
                    style="margin-left:10px" />

 </p:column > 
 <p:column > 
                <p:commandButton icon="ui-icon-search" update=":form:appDetail"
                    oncomplete="appDialog.show()" title="View Detail">
                    <f:setPropertyActionListener value="#{applicant}"
                        target="#{tableBean.selectedApplicant}" />
                </p:commandButton>

 </p:column > 
            </p:dataList>
于 2013-07-13T12:35:56.573 回答