JSF:使用 Icefaces 组件上传文件的问题

2023-12-02

我想得到FileUpload与 Icefaces 配合使用的功能ace:文件条目 but my fileUploadListener服务器上未调用,代码如下:

xhtml 片段:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ace="http://www.icefaces.org/icefaces/components"
      xmlns:ice-cc="http://www.icesoft.com/icefaces-composite-comps"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ice="http://www.icesoft.com/icefaces/component">
<h:head>
    <link rel="stylesheet" type="text/css" href="/xmlhttp/css/rime/rime.css"/>
</h:head>
<h:body>
    <h:form enctype="multipart/form-data">
        <ace:fileEntry id="fileEntryComp"
                       label="File Entry"
                       relativePath="uploaded"
                       fileEntryListener="#{fileUpload.uploadFile}"/>
        <h:commandButton value="Upload File"/>
    </h:form>
</h:body>
</html>

爪哇片

public void uploadFile(FileEntryEvent event)
    {
        FileEntry fileEntry = (FileEntry) event.getSource();
        FileEntryResults results = fileEntry.getResults();
        for (FileEntryResults.FileInfo fileInfo : results.getFiles())
        {
            if (fileInfo.isSaved())
            {
                log.debug("########### FILE IS SAVED ########");
            }
        }
    }

日志信息:

    FINE  lifecycle        - Entering RestoreViewPhase
FINE  lifecycle        - New request: creating a view for /trade_entry/UploadBlotter.xhtml
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - Created component with component type of 'javax.faces.ViewRoot'
FINE  application      - Created new view for /trade_entry/UploadBlotter.xhtml
FINE  application      - RenderKitId for this view as determined by calculateRenderKitId HTML_BASIC
FINE  lifecycle        - Exiting RestoreViewPhase
FINE  timing           -  [TIMING] - [2ms] : Execution time for phase (including any PhaseListeners) -> RESTORE_VIEW 1
FINE  lifecycle        - render(com.sun.faces.context.FacesContextImpl@1dc6429)
FINE  lifecycle        - Entering RenderResponsePhase
FINE  lifecycle        - About to render view /trade_entry/UploadBlotter.xhtml
FINE  application      - Building View: /trade_entry/UploadBlotter.xhtml
FINE  application      - Created component with component type of 'javax.faces.Output'
FINE  component        - /trade_entry/UploadBlotter.xhtml @7,9 <h:head> Component[-1351329185_508ba5ae] Created: javax
.faces.component.UIOutput
FINE  application      - Created component with component type of 'javax.faces.Output'
FINE  component        - /trade_entry/UploadBlotter.xhtml @10,9 <h:body> Component[-1351329185_508ba588] Created: java
x.faces.component.UIOutput
FINE  application      - Created component with component type of 'javax.faces.HtmlForm'
FINE  component        - /trade_entry/UploadBlotter.xhtml @11,13 <h:form> Component[-1351329185_508ba5e2] Created: jav
ax.faces.component.html.HtmlForm
FINE  application      - Created component with component type of 'org.icefaces.ace.component.FileEntry'
FINE  application      - Created component with component type of 'javax.faces.Output'
FINE  application      - Created component with component type of 'javax.faces.ComponentResourceContainer'
FINE  application      - Created component with component type of 'javax.faces.Output'
FINE  application      - Created component with component type of 'javax.faces.Output'
FINE  component        - /trade_entry/UploadBlotter.xhtml @15,70 <ace:fileEntry> Component[-1351329185_508ba5fc] Creat
ed: org.icefaces.ace.component.fileentry.FileEntry
FINE  application      - Created component with component type of 'javax.faces.HtmlCommandButton'
FINE  component        - /trade_entry/UploadBlotter.xhtml @16,47 <h:commandButton> Component[-1351329185_508ba5c9] Cre
ated: javax.faces.component.html.HtmlCommandButton
FINE  application      - Created component with component type of 'javax.faces.ComponentResourceContainer'
FINE  component        - No renderer-type for component j_id1
FINE  component        - No renderer-type for component javax_faces_location_BODY
FINE  application      - Rendering View: /trade_entry/UploadBlotter.xhtml
FINE  component        - No renderer-type for component javax_faces_location_HEAD
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  component        - No renderer-type for component _captureFileOnsubmit
FINE  application      - Begin writing marker for viewId /trade_entry/UploadBlotter.xhtml
FINE  application      - End writing marker for viewId /trade_entry/UploadBlotter.xhtml
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - URL pattern of the FacesServlet executing the current request .jsp
FINE  application      - Begin writing marker for viewId /trade_entry/UploadBlotter.xhtml
FINE  application      - End writing marker for viewId /trade_entry/UploadBlotter.xhtml
FINE  lifecycle        - Exiting RenderResponsePhase

现在,在当前状态下,我可以打开文件系统导航弹出窗口,并且可以选择文件,但是然后fileUploadListener应该被击中,但现在没有,我也能够获取我在服务器端设置的一些数据,因此服务器行程正在工作,我遇到的唯一问题是fileUploadListener还没打,有什么建议吗?

Update我仍在寻找答案,因为我无法成功地将文件上传到服务器。

Update 2现在正在得到Content is not allowed in prolog异常,不确定这到底意味着什么,这是堆栈跟踪:

    ERROR [Faces Servlet]  - Servlet.service() for servlet Faces Servlet threw exception: javax.faces.view.facelets.Facele
tException: Error Parsing /trade_entry/UploadBlotter.xhtml: Error Traced[line: 2] Content is not allowed in prolog.
        at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:417) [:2.1.7-SNAPSHOT]
        at com.sun.faces.facelets.compiler.SAXCompiler.doMetadataCompile(SAXCompiler.java:400) [:2.1.7-SNAPSHOT]
        at com.sun.faces.facelets.compiler.Compiler.metadataCompile(Compiler.java:130) [:2.1.7-SNAPSHOT]
        at com.sun.faces.facelets.impl.DefaultFaceletFactory.createMetadataFacelet(DefaultFaceletFactory.java:327) [:2.1.7-SNAPSHOT]
        at com.sun.faces.facelets.impl.DefaultFaceletFactory.access$200(DefaultFaceletFactory.java:93) [:2.1.7-SNAPSHOT]
        at com.sun.faces.facelets.impl.DefaultFaceletFactory$2.newInstance(DefaultFaceletFactory.java:166) [:2.1.7-SNAPSHOT]
        at com.sun.faces.facelets.impl.DefaultFaceletFactory$2.newInstance(DefaultFaceletFactory.java:164) [:2.1.7-SNAPSHOT]
        at com.sun.faces.facelets.impl.DefaultFaceletCache$2.newInstance(DefaultFaceletCache.java:94) [:2.1.7-SNAPSHOT]
        at com.sun.faces.facelets.impl.DefaultFaceletCache$2.newInstance(DefaultFaceletCache.java:89) [:2.1.7-SNAPSHOT]
        at com.sun.faces.util.ExpiringConcurrentCache$1.call(ExpiringConcurrentCache.java:99) [:2.1.7-SNAPSHOT]

我没有看到任何<h:form>围绕你的组件,你的代码中有什么吗? 我没有任何使用 Icefaces 的经验,但我已经习惯了 richFaces。 与一个

<rich:fileUpload immediate="true" id="fileUploadId" 
                        ajaxSingle="true" listHeight="70px" listWidth="500px"
                        uploadButtonClass="otherButton" styleClass="backgroundColorInput"
                        addButtonClass="otherButton"
                        fileUploadListener="#{paramActions.fileUploadListener}">
                        <a:support event="onuploadcomplete" reRender="paramsForm" />
                    </rich:fileUpload>

它需要包含在一个

<h:form id="paramsForm" enctype="multipart/form-data">

多部分/表单数据文件上传需要 enctype

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

JSF:使用 Icefaces 组件上传文件的问题 的相关文章

  • Eclipse 在源代码管理中保存操作

    我们希望找到一种在签入之前执行代码标准的 轻量级 方法 我们真的很喜欢使用 Eclipse 内置的想法保存操作 go to Preferences gt gt Java gt gt Editor gt gt Save Actions 其中有
  • 如何创建一个显示 Spinners 的 x 和 y 值的表格?

    我想创建一个位于图表右侧的表格 其中显示 2 列 x 和 y 值已输入到xSpin and ySpin旋转器 我已经画了一张我想要桌子放置的位置的图 我尝试过在网格窗格布局中使用文本框来创建表格并将值直接输入到文本框网格中 但是我无法将它们
  • Java:迭代 Collection 的最佳方法(此处为 ArrayList)

    今天 当我看到一段我已经使用了数百次的代码时 我很高兴地开始编码 迭代集合 此处为 ArrayList 出于某种原因 我实际上查看了 Eclipse 的自动完成选项 这让我想知道 在什么情况下以下循环比其他循环更好使用 经典的数组索引循环
  • OSGi:如果不取消服务会发生什么

    这是我获取 OSGi 服务的方式 ServiceReference reference bundleContext getServiceReference Foo class getName Foo foo Foo bundleContex
  • 从支持 bean 更新 PrimeFaces 数据表

    我在 bean 中使用 Schedule Timer 当员工注册从指纹设备获取数据时 它会更新变量 当 bean 中的变量更新时 我需要从支持 bean 更新 jsf 中的组件 我尝试使用 primefaces poll 组件 但它每次都会
  • wait() 在游戏中如何工作?

    在 playframework 的文档中here http www playframework org documentation 1 2 1 asynchronous已写 public static void loopWithoutBlo
  • 我需要什么库才能在 Java 中访问这个 com.sun.image.codec.jpeg?

    我正在用java创建一个图像水印程序 并导入了以下内容 import com sun image codec jpeg JPEGCodec import com sun image codec jpeg JPEGEncodeParam im
  • 使用 AES SecretKey 的 Java KeyStore setEntry()

    我目前正在 Java 中开发一个密钥处理类 特别是使用 KeyStore 我正在尝试使用 AES 实例生成 SecretKey 然后使用 setEntry 方法将其放入 KeyStore 中 我已经包含了代码的相关部分 The KS Obj
  • Calendar.getInstance(TimeZone.getTimeZone("UTC")) 不返回 UTC 时间

    我对得到的结果真的很困惑Calendar getInstance TimeZone getTimeZone UTC 方法调用 它返回 IST 时间 这是我使用的代码 Calendar cal Two Calendar getInstance
  • 编辑文件名在 JComboBox 中的显示方式,同时保持对文件的访问

    我对 Java 很陌生 对堆栈溢出也很陌生 我正在尝试利用 JMF API 创建一个用 Java 编码的简单媒体播放器 到目前为止 我已经能够设置一个简单的队列 播放列表来使用JComboBox called playListHolder
  • Javafx过滤表视图

    我正在尝试使用文本字段来过滤表视图 我想要一个文本字段 txtSearch 来搜索 nhs 号码 名字 姓氏 和 分类类别 我尝试过在线实施各种解决方案 但没有运气 我对这一切仍然很陌生 所以如果问得不好 我深表歉意 任何帮助将不胜感激 我
  • 欧洲中部时间 14 日 3 月 30 日星期五 00:00:00 至 日/月/年

    我尝试解析格式日期Fri Mar 30 00 00 00 CET 14至 日 月 年 这是我的代码 SimpleDateFormat formatter new SimpleDateFormat dd MM yyyy System out
  • 如何在JSTL中调​​用java方法? [复制]

    这个问题在这里已经有答案了 这可能是重复的问题 我只想调用不是 getter 或 setter 方法的方法例如 xyz 类的 makeCall someObj stringvalue Java类 Class XYZ public Strin
  • 我可以创建自定义 java.* 包吗?

    我可以创建一个与预定义包同名的自己的包吗在Java中 比如java lang 如果是这样 结果会怎样 这难道不能让我访问该包的受保护的成员 如果不是 是什么阻止我这样做 No java lang被禁止 安全管理器不允许 自定义 类java
  • 游戏内的java.awt.Robot?

    我正在尝试使用下面的代码来模拟击键 当我打开记事本时 它工作正常 但当我打开我想使用它的游戏时 它没有执行任何操作 所以按键似乎不起作用 我尝试模拟鼠标移动和点击 这些动作确实有效 有谁知道如何解决这个问题 我发现这个问题 如何在游戏中使用
  • HQL Hibernate 内连接

    我怎样才能在 Hibernate 中编写这个 SQL 查询 我想使用 Hibernate 来创建查询 而不是创建数据库 SELECT FROM Employee e INNER JOIN Team t ON e Id team t Id t
  • 为什么这个作业不起作用?

    我有课Results which extends ArrayList
  • 如何使用 JSch 将多行命令输出存储到变量中

    所以 我有一段很好的代码 我很难理解 它允许我向我的服务器发送命令 并获得一行响应 该代码有效 但我想从服务器返回多行 主要类是 JSch jSch new JSch MyUserInfo ui new MyUserInfo String
  • hashcode 的默认实现为以相同方式构造的对象返回不同的值

    我在这里编写一个示例代码 public class Test private int i private int j public Test TODO Auto generated constructor stub public Test
  • PrimeFaces 对话框参考父级

    我有一个 xhtml 页面 显示带有条目的数据表 我还有一个用于插入新条目的按钮 该按钮显示一个包含表单的对话框 插入表格用作

随机推荐