【问题标题】:Update datatable after fileupload using PrimeFaces使用 PrimeFaces 上传文件后更新数据表
【发布时间】:2014-06-19 16:12:54
【问题描述】:

下面是我的文件上传页面的代码,我不知道为什么上传完成后,如果上传成功与否,它不会更新我的数据表。我可以在更新后执行类似的操作,但不认为 fileupload 命令支持。我在列表中做了一个系统,它确实包含值,因此列表已完全填充并准备好显示,但我的数据表没有显示任何内容?我错过了什么吗?

  • Tomcat 7.0
  • JSF 2.2.1
  • Chrome/IE/Firefox
  • PrimeFaces 5.0
    <?xml version="1.0" encoding="UTF-8"?>
<!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:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui">
<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:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core"
    template="templates/template.xhtml">
    <ui:define name="title">Ingest</ui:define>
    <ui:define name="metadata">



    </ui:define>
        <ui:define name="content">          
<h:form>
    <p:fileUpload fileUploadListener="#{ingestBean.ingestListener}"
                  label="choose" invalidFileMessage="Invalid file: "
                  allowTypes="/(\.|\/)(xml)$/" multiple="true" update="@form">
    </p:fileUpload>

     <p:dataTable var="errors" value="#{ingestBean.errorList}" id="errorTable">
        <p:column headerText="File Name">
            <h:outputText value="#{errors.fileName}" />
        </p:column>

        <p:column headerText="Status">
            <h:form>
                <h:commandLink action="#{ingestBean.getErrorInfo}"
                               value="errors.status">
                    <f:param name="id" value="#{errors.id}" />
                </h:commandLink>
            </h:form>
        </p:column>
    </p:dataTable>
</h:form>

    </ui:define>
</ui:composition>
</html>

编辑:经过大量测试和代码重写后,我已经让它部分工作,但它似乎不喜欢在我的模板代码中呈现......所以我想知道我的模板是否有问题代码。

模板代码:

  <!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:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://java.sun.com/jsf/core">
<f:view contentType="text/html" id="fview">

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><ui:insert name="title">Page template with PrimeFaces</ui:insert></title>
    <ui:debug />
    <f:metadata>
        <ui:insert name="metadata" />
    </f:metadata>

    <h:head>
        <style>
#leftPanel {
    z-index: 1 !important;
}

#leftPanel div {
    overflow: visible;
}

</style>


    </h:head>

    <h:body onload="statusDialog.hide();">
        <h:outputStylesheet library="css" name="style.css" />
        <p:ajaxStatus onstart="statusDialog.show();"
            onsuccess="statusDialog.hide();" />
        <p:layout fullPage="true" resizeTitle="resize"
            style="background-color:#FFFFFF;">
            <p:layoutUnit position="north" size="68" id="north">
                <ui:include src="header.xhtml" />
            </p:layoutUnit>
            <p:layoutUnit position="west" size="202" header="Menu" id="leftPanel">
                <ui:include src="menu.xhtml" />
            </p:layoutUnit>
            <p:layoutUnit styleClass="layoutUnitCenter" position="center">
                <h:form id="mainForm">
                    <ui:insert name="content" />
                </h:form>
            </p:layoutUnit>

        </p:layout>


    </h:body>

</f:view>
</html>

【问题讨论】:

  • 好吧,要明确的是,不需要包含多部分表单数据,所以谢谢,但不,必须包含所有不正确的代码我能够显示出了什么问题,我现在是'我添加正文不会帮助任何人......我在我的本地以及部署的版本上下载并安装了tomcat!

标签: ajax jsf file-upload primefaces datatable


【解决方案1】:

像我所有的代码一样经过大量测试、删除和重写后,我发现这是布局和&lt;f:view&gt; 的愚蠢错误,所以我删除了它并

<p:ajaxStatus onstart="statusDialog.show();"
            onsuccess="statusDialog.hide();" />

一切似乎都运行良好!

【讨论】:

    猜你喜欢
    • 2015-07-16
    • 1970-01-01
    • 1970-01-01
    • 2015-01-14
    • 2017-08-17
    • 2015-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多