繁体   English   中英

JSF PRIMEFACES中的选定值未显示

[英]Selected Valued in JSF PRIMEFACES not been displayed

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

<?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;
    }





}

如果列表未由p:column包围,则p:commandButtonp:commandLink操作在数据表,数据列表或后备Bean中由List填充的任何组件内均不起作用。

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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM