我面临一个特殊的问题。我有一个基于 SpringBoot、JoinFaces 和 PrimeFaces 6.2 的单页应用程序。该页面主要有一个带有两个选项卡的手风琴。
Tab 1 - has a <p:fileUpload> //user uploads XML files using it
Tab 2 - has a <p:layout> //the selected XML file's content is displayed here, segregated into two <p:layoutunit>
在 Accordion 之后,我有一个带有提交按钮的工具栏,通过它我将选定的 XML 发送到将 XML 数据转换为 PDF 的后端服务。然后我使用 PrimeFaces-Extension 显示<pe:documentViewer>
PDF<p:dialog>
问题:
在我单击浏览器上的刷新之前,流程运行良好。如果我刷新页面,我会注意到<p:fileUpload>
and的 CSS<p:layout>
出错了。(此外,<p:fileUpload>
停止工作以及)。
观察 1:
当我比较 HTML 源代码时,刷新前后我看到刷新后,页面没有以下内容<head>
:
<link type="text/css" rel="stylesheet" href="/javax.faces.resource/fileupload/fileupload.css.xhtml?ln=primefaces&v=6.2" />
<script type="text/javascript" src="/javax.faces.resource/fileupload/fileupload.js.xhtml?ln=primefaces&v=6.2"></script>
<link type="text/css" rel="stylesheet" href="/javax.faces.resource/layout/layout.css.xhtml?ln=primefaces&v=6.2" />
<script type="text/javascript" src="/javax.faces.resource/layout/layout.js.xhtml?ln=primefaces&v=6.2"></script>
知道可能是什么原因造成的以及如何纠正吗?
观察 2:
bean KWOMTesterController 当前标记为@Named
。如果我也用它进行注释javax.faces.view.ViewScoped
,那么 UI 问题就解决了,但是<pe:documentViewer>
抱怨缺少 PDF(bean 有一个DefaultStreamedContent
字段,我在其中存储 PDF 数据)。
代码片段: 这是我的 XHTML 片段:
<p:accordionPanel id="mainpanel" activeIndex="0" binding="#{kwomTesterController.accordian}" cache="false">
<p:tab title="Select target environment and KWOM XML">
<p:panel>
<p:fileUpload update=":mainform" label="Select KWOM XML"
value="#{kwomTesterController.selectedFileName}" multiple="false" skinSimple="false" auto="true"
fileUploadListener="#{kwomTesterController.handleUpload}" style="margin-top:20px" mode="advanced"/>
</p:panel>
</p:tab>
<p:tab title="View/Edit selected KWOM XML " >
<p:layout style="width:100%;height:360px;">
<p:layoutUnit position="west" resizable="false" size="400" header="Configuration section">
...
...
...
</p:layoutUnit>
<p:layoutUnit position="center" header="Data section" style="overflow:hidden !important">
<p:inputTextarea rows="20" cols="138" autoResize="false" style="resize: none;" id="contentarea"
value="#{kwomTesterController.data}" />
</p:layoutUnit>
</p:layout>
</p:tab>
</p:accordionPanel>