I'm facing a peculiar issue. I have a single page app based on SpringBoot, JoinFaces and PrimeFaces 6.2. The page primarily has an Accordion with two tabs.
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>
After the Accordion I have a toolbar with a submit button by which I send the selected XML to a back end service that converts the XML data into a PDF. I then display the PDF using PrimeFaces-Extension's <pe:documentViewer>
inside a <p:dialog>
The issue:
The flow works fine till I click on refresh on the browser. If I refresh the page, I notice the CSS for the <p:fileUpload>
and <p:layout>
goes wrong. (Also, the <p:fileUpload>
stops working as well).
Observation 1:
When I compare the HTML source, before and after the refresh I see that after refresh, the page doesn't have these includes under <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>
Any idea what may be causing this and how to correct it?
Observation 2:
The bean KWOMTesterController is currently marked with @Named
. If I annotate it with javax.faces.view.ViewScoped
as well, then the UI issue is resolved, but the <pe:documentViewer>
complains of missing PDF (the bean has a DefaultStreamedContent
field, where I store the PDF data).
Code snippet: Here is my XHTML snippet:
<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>