dataTable中的filteredValue属性未正确更新

时间:2018-06-15 22:35:15

标签: jsf primefaces

我有这个.xhtml

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

        <h:form id="form">

            <p:panel>
                <p:selectOneMenu 
                    id="cursoOneMenu" label="Curso" required="true"
                    value="#{bean.curso}"                   
                    filter="true" filterMatchMode="contains"
                    converter="#{cursoConverter}">
                    <p:ajax update="@form"listener="#{bean.onChangeCurso}"/>
                       <f:selectItems value="#{bean.cursos}" var="item" itemValue="#{item}" itemLabel="#{item.descricao}"/>
                </p:selectOneMenu>
            </p:panel>

            <p:dataTable 
                id="disciplinasDataTable"
                value="#{bean.disciplinas}"
                filteredValue="#{atividadesComplementaresCalculoManagedBean.entidades}"
                widgetVar="disciplinasWidget" 
                var="item"
                paginator="true" 
                paginatorPosition="bottom"
                filterEvent="enter"
                rowsPerPageTemplate="5,10,20,40"
                rows="5"
                emptyMessage="Nenhum registro encontrado.">

                <p:column headerText="#" sortBy="#{item.descricao}" filterBy="#{item.descricao}" >
                    <h:outputText value="#{item.descricao}"/>
                </p:column>
            </p:dataTable>

        </h:form>

    </ui:composition> 

使用此.java控制上面的页面:

package br.admin;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Inject;
import javax.inject.Named;

import br.business.DisciplinaBean;
import br.business.CursoBean;
import br.pojo.Curso;
import br.pojo.Disciplina;

@Named
@ConversationScoped
public class Bean implements Serializable {

    private static final long serialVersionUID = 1L;

    private Curso curso;
    private List<Curso> cursos;
    private List<Disciplina> disciplinas;
    private List<Disciplina> disciplinasFiltradas;

    @Inject DisciplinaBean disciplinaBusiness;

    @PostConstruct
    public void inicializar() {

        disciplinaBusiness.listar();
    }

    public void atualizarLista() {

        if(curso != null) {
            disciplinas = disciplinaBusiness.listar(curso); 
        }
    }

    public void onChangeCurso() {
        atualizarLista();
    }

    public List<Disciplina> getDisciplinasFiltradas() {
        return disciplinasFiltradas;
    }

    public void setDisciplinasFiltradas(List<Disciplina> disciplinasFiltradas) {
        this.disciplinasFiltradas = disciplinasFiltradas;
    }

    public Curso getCurso() {
        return curso;
    }

    public void setCurso(Curso curso) {
        this.curso = curso;
    }

    public List<Disciplina> getDisciplinas() {
        return disciplinas;
    }

    public void setDisciplinas(List<Disciplina> disciplinas) {
        this.disciplinas = disciplinas;
    }

    public List<Curso> getCursos() {
        return cursos;
    }

    public void setCursos(List<Curso> cursos) {
        this.cursos = cursos;
    }
}

我试图找到关于&#34;最好的实践和#34;的一些文件。使用filteredValue,但我无法找到它,即使在primefaces doccumentation中也是如此。

我遇到的问题是,当我第一次更改选择项时,dataTable不会更新,当我第二次更改时,则dataTable更新,但所显示的数据对应于中选择的值第一次。当我删除filteredValue属性时,dataTable会正常更新。 Somone可以解释一下发生了什么?

如果我不够清楚,请发表评论,我会更新我的问题 我使用的是wildfly 11,java 9和primefaces 6.2

0 个答案:

没有答案