[JBoss Seam] - Open PDF in IE
by jpb2
Hello,
I´m using Seam 1.1.0 and it´s great.
There´s a Seam-Component for Japser Reports that´s working fine.
However opening PDF (inline) in InternetExplorer requiers a hack.
See http://xmlgraphics.apache.org/fop/0.93/servlets.html
Notes on Microsoft Internet Explorer
Some versions of Internet Explorer will not automatically show the PDF...However, Internet Explorer can still be used to download the PDF so that it can be viewed later....
..Use an URL ending in .pdf, like http://myserver/servlet/stuff.pdf. Yes, the servlet can be configured to handle this. If the URL has to contain parameters, try to have both the base URL as well as the last parameter end in .pdf, if necessary append a dummy parameter, like http://myserver/servlet/stuff.pdf?par1=a&par2=b&d=.pdf. The effect may depend on IEx version.
I was trying to append a dummy=.pdf parameter to the url using pages.xml, but the dummy-parameter is not appended at the very end, because Seam´s Redirect Filter appends the ConversationId to the url.
I know, that ist not the job of Seam to support an ugly workaround for IE to open PDF inline. But I hope, that someone can help me to solve this problem.
Thanks
jpb
Here´s the code to produce the PDF on the fly:
public String makePdf() {
| ...
| JRBeanCollectionDataSource jrDataSource = new JRBeanCollectionDataSource(items);
| Map paramMap = new HashMap();
|
| try {
| JasperPrint jasperPrint = JasperFillManager.fillReport(productReport, paramMap, jrDataSource);
| HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
| ServletOutputStream out = response.getOutputStream();
|
| ByteArrayOutputStream baos = new ByteArrayOutputStream();
| JasperExportManager.exportReportToPdfStream(jasperPrint, baos);
|
| response.setContentType("application/pdf");
| response.setHeader("Expires", "0");
| response.setHeader("Cache-Control",
| "must-revalidate, post-check=0, pre-check=0");
| response.setHeader("Pragma", "public");
| String filename = "Produktliste.pdf";
| response.setHeader("Content-Disposition", "inline; filename=\"" + filename + "\"");
|
| // contentlength required for MSIE
| response.setContentLength(baos.size());
|
| baos.writeTo(out);
| out.flush();
| out.close();
|
| FacesContext.getCurrentInstance().responseComplete();
| ...
|
| return Constants.View.REDIRECT.getNav();
| }
|
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4007894#4007894
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4007894
19 years, 2 months
[JCA/JBoss] - Re: EJB3 - XA datasource - Transactions - XAER_OUTSIDE
by apill
I ran the following code and it successfully updated the database within an XA transaction. I also tested rolling back the tx and this worked successfully.
Is there anything else you would like me to test?
| package test;
|
| import java.io.Serializable;
| import java.sql.Connection;
| import java.sql.Statement;
| import java.util.Arrays;
| import java.util.Random;
|
| import javax.sql.XAConnection;
| import javax.transaction.xa.XAException;
| import javax.transaction.xa.XAResource;
| import javax.transaction.xa.Xid;
|
| import com.ibm.db2.jcc.DB2XADataSource;
|
| public class Test
| {
| public static void main(String[] args) throws Exception
| {
|
| DB2XADataSource xaDataSource = new DB2XADataSource();
| xaDataSource.setDatabaseName("ZCOREINV");
| xaDataSource.setUser("zcoreinv");
| xaDataSource.setPassword("zcoreinv");
| xaDataSource.setPortNumber(50000);
| xaDataSource.setServerName("localhost");
| xaDataSource.setDriverType(4);
|
| XAConnection xaConnection = xaDataSource.getXAConnection();
| XAResource xaResource = xaConnection.getXAResource();
| XidImpl xid = new XidImpl();
|
| final Connection connection = xaConnection.getConnection();
| final Statement statement = connection.createStatement();
|
| try
| {
| xaResource.start(xid, XAResource.TMNOFLAGS);
| statement.executeUpdate("DELETE FROM ZCOREINV.COUNTRY WHERE ID = '53'");
| xaResource.end(xid, XAResource.TMSUCCESS);
|
| int ret = xaResource.prepare(xid);
|
| xaResource.commit(xid, false);
| }
| catch (XAException e)
| {
| e.printStackTrace();
| }
| finally
| {
| statement.close();
| connection.close();
| xaConnection.close();
| }
|
| }
|
| public static class XidImpl implements Serializable, Xid
| {
| private static final long serialVersionUID = -2227021688745286343L;
|
| private static Random random = new Random();
|
| private int formatId = 876;
|
| private byte[] globalTransactionId;
|
| private byte[] branchQualifier = new byte[0];
|
| private transient String cachedToString;
|
| private transient int cachedHashCode;
|
| public XidImpl()
| {
| globalTransactionId = new byte[10];
| random.nextBytes(globalTransactionId);
| }
|
| public int getFormatId()
| {
| return formatId;
| }
|
| public byte[] getGlobalTransactionId()
| {
| return globalTransactionId;
| }
|
| public byte[] getBranchQualifier()
| {
| return branchQualifier;
| }
|
| public boolean equals(Object object)
| {
| if (object == this)
| return true;
| if (object == null || object instanceof Xid == false)
| return false;
|
| Xid other = (Xid) object;
| return
| (
| formatId == other.getFormatId() &&
| Arrays.equals(globalTransactionId, other.getGlobalTransactionId()) &&
| Arrays.equals(branchQualifier, other.getBranchQualifier())
| );
| }
|
| public int hashCode()
| {
| if (cachedHashCode == 0)
| {
| cachedHashCode = formatId;
| for (int j = 0; j < globalTransactionId.length; ++j)
| cachedHashCode += globalTransactionId[ j ];
| }
| return cachedHashCode;
| }
|
| public String toString()
| {
| if (cachedToString == null)
| {
| StringBuffer buffer = new StringBuffer();
| buffer.append("XidImpl[FormatId=").append(getFormatId());
| buffer.append(" GlobalId=").append(new String(getGlobalTransactionId()).trim());
| byte[] branchQualifer = getBranchQualifier();
| buffer.append(" BranchQual=");
| if (branchQualifer == null)
| buffer.append("null");
| else
| buffer.append(new String(getBranchQualifier()).trim());
| buffer.append(']');
| cachedToString = buffer.toString();
| }
| return cachedToString;
| }
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4007882#4007882
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4007882
19 years, 2 months