p:对话框没有出现在大的p:dataTable之上

时间:2014-02-04 17:40:32

标签: javascript jsf primefaces

我正在使用PrimeFaces 4.0。虽然使用p:dialog组件工作正常,但我遇到了一些与p:dataTable相结合的问题。

当dataTable只有几个元素时,对话框可以正常工作。当dataTable包含大量项目时,任何会导致Web浏览器滚动条出现的内容都不会出现。

没有javascript错误,它似乎是一个纯粹的UI问题,与屏幕上对话框覆盖的位置有关。它将根据网页的长度尝试将自己置于网页中心。不知何故,对话似乎迷失了方向。如果我使用键盘进行导航(即点击确切数量的标签笔划以确保突出显示对话框的关闭按钮),我们仍然可以与它进行交互,然后它会响应。

有没有人见过这个问题?

这是带有对话框的XHTML:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
            template="/layout/layout-padrao.xhtml"
            xmlns:h="http://xmlns.jcp.org/jsf/html"
            xmlns:p="http://primefaces.org/ui"
            xmlns:f="http://xmlns.jcp.org/jsf/core">

    <ui:define name="content"> 

    <f:event type="preRenderView" listener="#{downloadController.preRenderView()}"/>
    <h:form id="form">
        <p:blockUI block="form" trigger="tableFilelist ">
            Reordenando NNN3...
        </p:blockUI>

        <p:dialog id="dlgConfigFiltro" header="Configuração de Filtro" widgetVar="dlgConfigFiltro" modal="true">
            Escolha os tipos de conteúdo que deseja ver.
            <br/>
            <br/>
            <p:selectBooleanCheckbox id="dlgConfigFiltro_NNN1" value="#{downloadController.flagFiltroNNN1}"/>
            <h:outputLabel value="NNN1" for="dlgConfigFiltro_NNN1"/>
            <br/>
            <p:selectBooleanCheckbox id="dlgConfigFiltro_NNN2" value="#{downloadController.flagFiltroNNN2}"/>
            <h:outputLabel value="Música" for="dlgConfigFiltro_NNN2"/>
            <br/>
            <p:selectBooleanCheckbox id="dlgConfigFiltro_NNN3" value="#{downloadController.flagFiltroNNN3}"/>
            <h:outputLabel value="NNN3" for="dlgConfigFiltro_NNN3"/>
            <br/>
            <br/>
            <div style="text-align: right">
                <p:commandButton id="dlgConfigFiltro_btnFechar" value="Fechar" action="#{downloadController.dlgFiltroApply()}"/>
            </div>

            <p:ajax event="close" update="tableFilelist" listener="#{downloadController.dlgFiltroOnClose()}"/>
        </p:dialog>

        <center>
        <table style="border: 0px none; width: 80%">
            <tr>
                <td style="text-align: left;">
                    <p:inputText value="#{downloadController.filtro}" size="40" id="txtFiltro"/>
                    &nbsp;
                    <p:commandButton id="btnFiltrar" value="Filtrar" action="#{downloadController.filtrar()}" update="tableFilelist"/>
                    &nbsp;
                    <p:commandButton 
                        id="btnReset"
                        value="Limpar filtro" 
                        icon="ui-icon-arrowreturnthick-1-w" 
                        action="#{downloadController.reset()}"
                        update="tableFilelist txtFiltro"
                        />
                    &nbsp;
                    <p:commandButton 
                        id="btnConfigFiltro"
                        value="Configurar filtro" 
                        actionListener="#{downloadController.dlgFiltroOpen()}"
                        update="dlgConfigFiltro"
                        />
                    <p:defaultCommand target="btnFiltrar"/>
                </td>
                <td style="text-align: right;">
                    <p:commandButton 
                        id="btnAtualizar"
                        value="Atualizar" 
                        icon="ui-icon-refresh" 
                        action="#{downloadController.refresh()}"
                        update="tableFilelist"
                        />
                </td>
            </tr>
        </table>
        <p/>
        <p:dataTable 
            id="tableFilelist"
            emptyMessage="Diretório vazio"
            value="#{downloadController.filelist}" 
            var="file"
            style="width:80%"
            >
            <p:column headerText="Nome">
                <a href="#{file.downloadPath}">#{file.name}</a>
            </p:column>
            <p:column headerText="Tamanho" style="width:120px">
                <h:outputText value="#{file.sizeDisplay}"/>
            </p:column>
            <p:column headerText="Data" style="width:150px">
                <h:outputText value="#{file.creationDisplay}"/> 
            </p:column>
        </p:dataTable>
        </center>
        <p:blockUI block="form" trigger="btnFiltrar btnAtualizar btnReset dlgConfigFiltro_btnFechar">
            Por favor, aguarde...
        </p:blockUI>
    </h:form>
    </ui:define>

</ui:composition>

这是控制器bean

package net.jhm.jsf.controller;

import java.io.IOException;
import java.io.Serializable;
import java.nio.file.Path;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.inject.Inject;
import javax.inject.Named;
import net.jhm.entity.service.SysConfigService;
import net.jhm.jsf.model.DownloadFile;
import net.jhm.jsf.model.DownloadFileComparator_Creation;
import net.jhm.security.annotation.Secure;
import net.jhm.util.DirectoryWatchService;
import org.apache.commons.io.FileSystemUtils;
import org.apache.commons.lang3.StringUtils;
import org.primefaces.context.RequestContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Named
@SessionScoped
public class DownloadController implements Serializable {

    private Logger logger = LoggerFactory.getLogger(DownloadController.class);

    @Inject
    private SysConfigService sysconfig;

    private String basedir;

    @Inject
    private DirectoryWatchService dws;

    private String filtro;

    private List<DownloadFile> files = new LinkedList<>();

    private DownloadFileComparator_Creation dfcCreation = new DownloadFileComparator_Creation();

    private Boolean flagFiltroNNN1 = true;
    private Boolean flagFiltroNNN2 = true;
    private Boolean flagFiltroNNN3 = false;

    public Boolean getFlagFiltroNNN1() {
    return flagFiltroNNN1;
    }

    public void setFlagFiltroNNN1(Boolean flagFiltroNNN1) {
    this.flagFiltroNNN1 = flagFiltroNNN1;
    }

    public Boolean getFlagFiltroNNN2() {
    return flagFiltroNNN2;
    }

    public void setFlagFiltroNNN2(Boolean flagFiltroNNN2) {
    this.flagFiltroNNN2 = flagFiltroNNN2;
    }

    public Boolean getFlagFiltroNNN3() {
    return flagFiltroNNN3;
    }

    public void setFlagFiltroNNN3(Boolean flagFiltroNNN3) {
    this.flagFiltroNNN3 = flagFiltroNNN3;
    }

    public void setFiltro(String filtro) {
    this.filtro = filtro;
    }

    public String getFiltro() {
    return filtro;
    }

    public void preRenderView() throws IOException {
    refresh();
    }

    @PostConstruct
    public void init() {
    basedir = sysconfig.get("net.jhm.intra.complete", null);
    if ( basedir == null ) {
        throw new RuntimeException("net.jhm.intra.complete is not defined in SysConfig");
    }
    dws.setBasedir(basedir);
    dws.getExtensionList().add("ext1");
    try {
        reset();
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
    }

    public void dlgFiltroOpen() {
    RequestContext.getCurrentInstance().execute("PF('dlgConfigFiltro').show()");
    }

    public void dlgFiltroApply() {
    RequestContext.getCurrentInstance().execute("PF('dlgConfigFiltro').hide()");
    }

    public void dlgFiltroOnClose() throws IOException {
    dws.getExtensionList().clear();
    refresh();
    }

    public void filtrar() {
    }

    public void reset() throws IOException {
    setFiltro(null);
    }

    public void refresh() throws IOException {
    dws.updateDirectories();
    }

    public List<DownloadFile> getFilelist() {
    if ( !StringUtils.isBlank(getFiltro()) ) {
        files = new LinkedList();
        for (DownloadFile df : dws.getFiles()) {
            String[] arr = getFiltro().split(" ");
            boolean bMismatch = false;
            for ( String sfiltro : arr ) {
                if ( arr != null && !df.getName().toUpperCase().contains(sfiltro.toUpperCase()) ) {
                    bMismatch = true;
                    break;
                }
            }
            if ( !bMismatch ) {
                files.add(df);
            }
        }
    }
    else {
        files = new LinkedList(dws.getFiles());
    }
    Collections.sort(files, dfcCreation);
    return files;
    }

}

0 个答案:

没有答案