p:dataTable p:ajax CDI f:param cid - pe:documentViewer

UI Components for JSF
Post Reply
arnieDps
Posts: 12
Joined: 22 Feb 2022, 16:47

05 Nov 2022, 04:26

PF 11 - JSF 2.3 - CDI - Wildfly 26

I have a single page with a left sidebar and a right content area where I need to display a PDF file.

p:media doesn't work. pe:documentViewer at least makes the call to the streamed content method (which has content).

The UI presents with the sidebar pre-populated with "packet" information. The content area "blank" as no "document" is selected in the sidebar.

The sidebar has a dataTable listing the files related to the "packet" which the human must review.

I have an ajax event/rowSelect set up in the dataTable to populate the underlying object and it is being fired.

But when the ajax call completes, the pe:documentViewer appears and instead of showing the PDF, I get:

PDF.js v2.11.338 (build: dedff3c98)
Message: Missing PDF "https://hdqitsw552186.tle.dps:8443/tpst ... _NOT_FOUND".

WHY? And how do I fix this?

I strongly suspect that it is failing because the AJAX call is not passing the CDI cid parameter.

Am I missing something?

NOTiFY
Posts: 393
Joined: 25 May 2016, 22:57

08 Nov 2022, 11:48

I have a similar issues with "p:dataTable " & "p:ajax" etc. using WildFly 26.x/27.x etc.

Looked at your post:

Code: Select all

PDF.js v2.11.338 (build: dedff3c98)
Message: Missing PDF "https://hdqitsw552186.tle.dps:8443/tpst ... _NOT_FOUND".
Any more info?

Also add some 'layout' please.
PF 13.0.0--Jakarta. Jakarta Faces 4.0.1/Kotlin Multiplatform 1.9.10
Mojarra 4.0.2, OmniFaces 4.2
WildFly 29.0.1.Final 'preview' Jakarta EE 10.0.0
JDK 20.0.2, Kotlin 1.9.10, Gradle 8.3 Groovy DSL, MongoDB 7.0.0
IntelliJ IDEA 2023.2.1, macOS Ventura 13.5.1

arnieDps
Posts: 12
Joined: 22 Feb 2022, 16:47

14 Nov 2022, 21:18

Layout? I'm hoping you mean the XHTML layout? The following file is the right sidebar/content area of the page. It is ui:include'd into an actual page along with the left sidebar. There is only one h:form and its in the actual page file (not this "subfile").

Code: Select all

<!DOCTYPE html>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pe="http://primefaces.org/ui/extensions"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:core="http://java.sun.com/jsp/jstl/core"
	xmlns:fmt="http://java.sun.com/jsp/jstl/fmt"
	xmlns:components="http://java.sun.com/jsf/composite/components">

	<p:outputPanel id="infoPacketReviewEditFilePanel">

		<h:panelGroup class="ui-g" layout="block"
			rendered="#{not empty infoPacketReviewDTOUI.selectedFile}">

			<div class="ui-g-12">
				<span class="ui-g-6">
					<p:commandLink value="#{messages.getString('packetReviewEdit.label.contentbar.closeFile')}"
						actionListener="#{infoPacketReviewEdit.clearDocument}"
						process="@this" update="infoPacketReviewEditPanel">
						<f:param name="cid"
							value="#{javax.enterprise.context.conversation.id}" />
					</p:commandLink>
				</span>
				<span class="ui-g-6">
					<span style="float: right;"> 
						<p:splitButton
							icon="pi pi-bolt"
							value="#{messages.getString('application.label.cmdAction')}">

							<p:menuitem
								actionListener="#{infoPacketReviewEdit.acceptDocument}"
								value="#{messages.getString('packetReviewEdit.label.contentbar.statusAccepted')}"
								process="@this"
								update="infoPacketReviewEditFilePanel,globalMessagesPanel">
								<f:param name="cid"
									value="#{javax.enterprise.context.conversation.id}" />
							</p:menuitem>

							<p:menuitem
								actionListener="#{infoPacketReviewEdit.rejectDocument}"
								value="#{messages.getString('packetReviewEdit.label.contentbar.statusRejected')}"
								process="@this"
								update="infoPacketReviewEditFilePanel,globalMessagesPanel">
								<f:param name="cid"
									value="#{javax.enterprise.context.conversation.id}" />
							</p:menuitem>

						</p:splitButton>
					</span>
				</span>
				
			</div>
			
			<div class="ui-g-12">
		
				<pe:documentViewer id="viewPdfDocument"
					value="#{infoPacketReviewDTOUI.streamedFileContent}"
					zoom="page-width" pagemode="thumbs" height="600px"
					name="#{infoPacketReviewDTOUI.selectedFile.originalFileName}"
					title="Packet File" 
					rendered="#{not empty infoPacketReviewDTOUI.selectedFile}" />

			</div>

		</h:panelGroup>

		<h:panelGroup class="ui-g-12" layout="block" style="text-align:center;" 
			rendered="#{empty infoPacketReviewDTOUI.selectedFile}" >
			<h:outputText
				value="#{messages.getString('packetReviewEdit.label.contentbar.noSelection')}" />
		</h:panelGroup>

	</p:outputPanel>

</ui:composition>

arnieDps
Posts: 12
Joined: 22 Feb 2022, 16:47

15 Nov 2022, 04:14

This is the event I have on my data table:

Code: Select all

<p:ajax event="rowSelect"
	listener="#{infoPacketReviewEdit.onFileDataRowSelect}"
	process="@form" 
	update="infoPacketReviewEditForm:infoPacketReviewEditFilePanel" 
	complete="refreshViewPdfDocument()"> 
	<f:param name="cid" value="#{javax.enterprise.context.conversation.id}" />									
</p:ajax>
and where I see the JS function refreshViewPdfDocument on the page, inside the datatable markup there is no invocation.

How do I get this work?

arnieDps
Posts: 12
Joined: 22 Feb 2022, 16:47

16 Nov 2022, 16:30

I'm finding posts that indicate the name parameter breaks both p:media and pe:documentViewer if the file does not in end in .PDF or sometimes .jsf (instead of .xhtml) etc.

I removed the parameter from my markup and now I get a different message from the PDF plugin (using pe:documentViewer):

PDF.js v2.11.338 (build: dedff3c98)
Message: Missing PDF "https://hdqitsw552186.tle.dps:8443/tpst ... nload=null".

So I changed my web.xml to:

Code: Select all

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
        <url-pattern>*.xhtml</url-pattern>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
and now get:

PDF.js v2.11.338 (build: dedff3c98)
Message: Missing PDF "https://hdqitsw552186.tle.dps:8443/tpst ... _NOT_FOUND".

again. Reverted to just:

Code: Select all

        <url-pattern>/faces/*</url-pattern>
        <url-pattern>*.xhtml</url-pattern>
Breakpoints on the method returning the streamed content indicate it is NOT even being called.

arnieDps
Posts: 12
Joined: 22 Feb 2022, 16:47

16 Nov 2022, 17:20

I realized my ajax markup was wrong:

Code: Select all

<p:ajax id="onRowSelect" event="rowSelect"
	listener="#{infoPacketReviewEdit.onFileDataRowSelect}"
	process="@form" 
	update="infoPacketReviewEditForm:infoPacketReviewEditFilePanel" 
	oncomplete="refreshViewPdfDocument()"> 
	<f:param name="cid" value="#{javax.enterprise.context.conversation.id}" />									
</p:ajax>
Had forgotten the "on" prefix on complete because the editor isn't showing me the tag info.

Now the JS is being called:

Code: Select all

function refreshViewPdfDocument() {
    var viewer = document.getElementById('infoPacketReviewEditForm:viewPdfDocument');
    if ( viewer == null ) {
	    alert("Could not find viewer component to refresh!");
	} else {
		viewer.contentDocument.location.reload();
	}
}		
but the viewer reload still isn't working, BUT, the message is different now:

Code: Select all

PDF.js v2.11.338 (build: dedff3c98)
Message: Missing PDF "https://hdqitsw552186.tle.dps:8443/tpstp-packet-review/javax.faces.resource/dynamiccontent.properties.xhtml?ln=primefaces&v=11.0.0&e=11.0.0&pfdrid=632f942e395a566754b8280e5c0334e6&pfdrt=sc&pfdrid_c=false&uid=91801b40-1388-4c64-8918-d974ca589e7e&download=BRD+-+DLD.PDF".
PDF file name is present now even though the name or download parameters are not present. Odd. If I add it back I get the old RES_NOT_FOUND message.

HOWEVER, now the getter where the already built StreamedContent is being called. Yeah! But in the server console:

Code: Select all

09:27:10,940 WARNING [org.primefaces.application.resource.StreamedContentHandler] (default task-92) Dynamic content resolved to null - skip streaming resource for ValueExpression: #{infoPacketReviewDTOUI.streamedFileContent}
So I'm at a loss here.

arnieDps
Posts: 12
Joined: 22 Feb 2022, 16:47

30 Nov 2022, 02:03

No body?

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

30 Nov 2022, 16:28

If you put together a PrimeFaces Test reproducer it would be easier for us to debug: https://github.com/primefaces/primefaces-test
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 22 guests