primefaces-extensions: Document Viewer: Empty (solved missing version resource number in URL)
Describe the bug
It used to work, but checked PF/PF-E 13/14/15 and in each version can’t make the viewer work:
<pe:documentViewer id="documentViewer1" width="100%" height="600px" url="#{someBean.url}" locale="pl"/>
<pe:documentViewer id="documentViewer2" width="100%" height="600px" value="#{someBean.content}" locale="pl"/>
where url returns full url to a REST service returning a document (URL itself works in browser), and content returns StreamedContent from the file.
public String getUrl() {
logger.info("getUrl");
return "https://server.domain.local:8443/app-web/rest/document/someuuid";
}
public StreamedContent getContent() {
logger.info("getContent");
File file = new File("/home/user/file.pdf");
return DefaultStreamedContent.builder()
.stream(() -> {
try {
return new FileInputStream(file);
} catch (Exception ex) {
throw new RuntimeException("Exception during createStreamedContent", ex);
}
})
.contentType(MimeType.fromExtension(file).getContentType())
.name(file.getName())
.contentLength(file.length())
.build();
}
and the REST service is:
@GET
@Path("{name}")
@Produces({"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.ms-excel", "application/pdf", "application/zip", "text/xml", "text/csv", "text/plain", "image/jpeg", "application/octet-stream"})
public Response getDocumentFile(@PathParam("name") String name) {
try {
logger.info("getDocumentFile");
File file = new File("/home/user/file.pdf");
if (file != null && file.exists()) {
return Response.ok(file, MimeType.fromExtension(file.getName()).getContentType())
.cacheControl(noCache)
.header("Pragma", "no-cache")
.expires(expires0)
//.header("Content-Disposition", String.format("attachment; filename=%s", file.getName()))
.header("Content-Disposition", "inline")
.header("Content-Length", file.length())
.build();
} else {
logger.error("Failure of getDocumentFile(%s)", name);
throw new WebApplicationException(Response.Status.BAD_REQUEST);
}
} catch (WebApplicationException ex) {
throw ex;
} catch (Throwable ex) {
logger.error(ex, "Exception during getDocumentFile(%s)", name);
throw new WebApplicationException(ex, Response.Status.INTERNAL_SERVER_ERROR);
}
}
This definitely worked before, and I’m not sure what to blame - PF version, Java version, Jakarta version, Wildfly version, security settings applied to Java and Wildfly? I’ve found the url the pdfviewer.html.jsf is called with, and when used separately it also throws up a blank viewer. The call to the REST service is never made.
Reproducer
No response
Expected behavior
No response
PrimeFaces Extensions version
14.0.8
JSF implementation
Mojarra
JSF version
4.0
Browser(s)
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 20 (9 by maintainers)
Yep I have this note for myself when I upgrade PDFViewer and forogt to do it!
Yep it WILL not work without that and I have said over and over that is a nonsense security requirement. The DocumentViewer requires the version URLS
we do this in the PF showcase pom.xml which is jetty and has a CountryRestService.java