pe:documentViewer 3.2.0 not working in PF5 5.2.6.

Community Driven Extensions Project
Post Reply
koekiebox
Posts: 50
Joined: 18 Mar 2014, 15:44

24 Jun 2015, 10:41

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:

Image

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

24 Jun 2015, 10:57

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

koekiebox
Posts: 50
Joined: 18 Mar 2014, 15:44

24 Jun 2015, 11:21

The component works on Firefox 32.0.3, both 5.2 and 5.2.6.

But when I am running Chrome 43.0.2357.130 (64-bit), it doesn't work on any of the 5.2.x versions. (Get the same JavaScript error).
Also ensured caches were cleared.

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

24 Jun 2015, 11:59

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


koekiebox
Posts: 50
Joined: 18 Mar 2014, 15:44

13 Nov 2015, 16:30

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>
The Attachment bean:

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());
        }
    }

koekiebox
Posts: 50
Joined: 18 Mar 2014, 15:44

14 Nov 2015, 10:28

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>

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 21 guests