Closed fcanevar closed 9 years ago
Please post a complete example (xhtml + bean), otherwise it will be closed.
@francesco-strazzullo Could you please check it? If you can't replicate, just close it as the user didn't provide a example.
Sorry, I've lost track of the ticket, I'll provide an example today
Sorry again for the delay and thank you very much. Here it is the example: index.xhtml
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:pe="http://primefaces.org/ui/extensions"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:form id="myform">
<p:growl id="myGrowl" autoUpdate="true" globalOnly="false" />
<p:commandButton id="button" immediate="true" partialSubmit="true"
process="@this" update="@widgetVar(dialogWv)"
actionListener="#{testBck.loadPage}"
oncomplete="PF('dialogWv').show()" value="Open">
</p:commandButton>
<p:dialog id="dialog" header="Test" widgetVar="dialogWv"
dynamic="true" resizable="false" draggable="true" modal="true"
minWidth="400" minHeight="300" minimizable="false"
maximizable="false" rendered="true" width="600px" height="500px">
<p:ajax event="close" listener="#{testBck.resetPage}" update="@form"
partialSubmit="true" process="@this" global="false" />
<ui:include src="#{testBck.page}" />
</p:dialog>
<!--
Uncomment to quickfix
<pe:documentViewer id="previewDummy" rendered="false" />
-->
</h:form>
</h:body>
</html>
TestBck.java
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class TestBck {
private String page;
public TestBck() {
resetPage();
}
public void loadPage() {
page = "/dialog.xhtml";
}
public void resetPage() {
page = "/empty.xhtml";
}
public String getPage() {
return page;
}
public StreamedContent getContent() {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Document document = new Document();
PdfWriter.getInstance(document, out);
document.open();
document.add(new Paragraph("Test"));
document.close();
return new DefaultStreamedContent(new ByteArrayInputStream(
out.toByteArray()), "application/pdf");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
dialog.xhtml
<?xml version="1.0" encoding="UTF-8" ?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions"
xmlns:smifn="http://www.sanmarcoweb.com/smifunctions">
<pe:documentViewer id="preview" value="#{testBck.content}" />
</ui:composition>
empty.xhtml
<?xml version="1.0" encoding="UTF-8" ?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:smifn="http://www.sanmarcoweb.com/smifunctions">
</ui:composition>
As you can see, if you don't uncomment the last line in the index.xhtml page you'll get always that error, otherwise you'll see the correct content.
Thanks a lot, Fabio
Ok Thanks i will look into it!
pe:documentViewer is included via a dynamic include, so the component is not available when building the view. This can't be fixed on our side. See: http://blog.primefaces.org/?p=1503
You need always to include primefaces extensions.js via:
I've a web-app MyFaces 2.2.7, PF 5.1.16 and PFext 3.0 and I'm trying to update it to PF 5.2.6 and PFext 3.2 .
Every time that I dynamically open a p:dialog with a pe:documentViewer inside I get this error in the Firefox console: "TypeError: window.parent.PrimeFacesExt is undefined" and I can't see the embedded PDF, if I refresh the page and reopen the dialog that I can see it...