Hi,
PDF Document Viewer is not working in PrimeFaces. I get a JavaScript error when using Chrome.
This problem seems to be different to the reported ones.
XHTML:
<pe:documentViewer height="600" width="800" value="#{attachmentBean.attachmentData}">
<f:param name="attachmentId" value="#{attachmentItem.attachmentId}"></f:param>
</pe:documentViewer>
EXAMPLE:
pe:documentViewer 3.2.0 not working in PF5 5.2.6.
-
- PrimeFaces Core Developer
- Posts: 3979
- Joined: 03 Dec 2010, 14:11
- Location: Bavaria, DE
- Contact:
Does it work with 5.2? It seems to work fine in the showcase.
Thomas Andraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
-
- PrimeFaces Core Developer
- Posts: 3979
- Joined: 03 Dec 2010, 14:11
- Location: Bavaria, DE
- Contact:
Then create a issue plz.
Thomas Andraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
PrimeFaces | PrimeFaces Extensions
Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE
Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko
Case created at: https://github.com/primefaces-extension ... issues/346
Code: Select all
<!--Handle PDF-->
<p:lightBox id="lightboxPDBTable" rendered="#{attachmentItem.contentTypePDF}">
<h:outputLink style="cursor: hand;" value="#">
<p:outputLabel style="cursor: hand;" value="#{attachmentItem.filename}"/>
</h:outputLink>
<f:facet name="inline">
<pe:documentViewer height="600" width="800" value="#{attachmentBean.attachmentData}">
<f:param name="attachmentId" value="#{attachmentItem.attachmentId}"></f:param>
</pe:documentViewer>
</f:facet>
</p:lightBox>
Code: Select all
/**
*
* @return
*/
public StreamedContent getAttachmentData() {
FacesContext context = FacesContext.getCurrentInstance();
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
return new DefaultStreamedContent();
}
//
else {
String attachmentId = context.getExternalContext().getRequestParameterMap().get(
WebParam.AttachmentId);
if(ObjectValidate.isEmpty(attachmentId))
{
throw new FlowJobException(
"Parameter '"+WebParam.AttachmentId
+"' not set. Unable to retrieve attachment.",
FlowJobException.ErrorCode.FIELD_VALIDATE);
}
Attachment attachmentById = this.attachmentApplication.getAttachmentById(new Long(attachmentId));
InputStream inputStream = this.attachmentApplication.getAttachmentInputStream(attachmentById);
return new DefaultStreamedContent(inputStream, attachmentById.getContentType().getDescription(), attachmentById.getName());
}
}
I was able to resolve the issue by putting the documentViewer in an iFrame light-box.
Code: Select all
<!--Handle PDF-->
<p:lightBox id="lightboxPDBTable" iframe="true" iframeTitle="#{attachmentItem.filename}"
rendered="#{attachmentItem.contentTypePDF}">
<h:outputLink value="form_container/document_viewer.xhtml?attachmentId=#{attachmentItem.attachmentId}"
title="#{attachmentItem.filename}">
<h:outputText value="#{attachmentItem.filename}"/>
</h:outputLink>
</p:lightBox>
-
- Information
-
Who is online
Users browsing this forum: No registered users and 24 guests