Hi, I tried this simple page while using Trinidad + Facelets + Ajax4jsf:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <tr:document xmlns:tr="http://myfaces.apache.org/trinidad" xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"> <a4j:mediaOutput element="object" cacheable="false" session="true" value="logo-simple.pdf" createContent="#{testBean.paint}" mimeType="application/pdf"/> </tr:document>
public class TestBean { public void paint(OutputStream out, Object data) throws IOException { if (data instanceof String) { InputStream file = FacesContext.getCurrentInstance(). getExternalContext(). getResourceAsStream((String)data); int size = file.available(); byte[] pdf = new byte[size]; file.read(pdf); file.close(); out.write(pdf); } } }
Sorry, I guess this is more relevant to ajax4jsf users forum, I'll move it there.