tapestry-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Ignatyev <kgignat...@yahoo.com>
Subject Re: How to create a link to a blob
Date Mon, 01 Aug 2005 19:59:24 GMT
Simply create a PDF service that will do that,
something like this:
in application.xml

 <service name="JasperToPDFService"
class="xxx.JasperToPDFService" />


public class JasperToPDFService extends
AbstractService{

  public static final String SERVICE_NAME =
"JasperToPDFService";

  public String getName(){
    return SERVICE_NAME;
  }

  /**
   * parameters[page,ognlExpressionToGetSource]
   * @param iEngineServiceView
   * @param cycle
   * @param responseOutputStream
   * @throws javax.servlet.ServletException
   * @throws java.io.IOException
   */
  public void service( IEngineServiceView
iEngineServiceView, IRequestCycle cycle,
ResponseOutputStream responseOutputStream ) throws
ServletException, IOException{
    Object[] params = getParameters( cycle ) ;
    String pageName = (String) params[0];
    String srcExpression = (String) params[1];
    responseOutputStream.setContentType(
"application/pdf" );
    HttpServletResponse response =
cycle.getRequestContext().getResponse();
    response.setHeader("Expires", "0");
    response.setHeader("Cache-Control",
"must-revalidate, post-check=0, pre-check=0");
    response.setHeader("Pragma", "public");
    response.setHeader("Content-Disposition",
"attachment; filename=\"" + pageName +".pdf\"");
    try{
      JasperPrint p = (JasperPrint) Ognl.getValue(
Ognl.parseExpression( srcExpression ), cycle.getPage(
pageName ) );
     
ConsoleServicesFactory.getJasperReportExecutor().exportReportToPDF(
p, response.getOutputStream());
    } catch( Exception e ){
      throw new ServletException( e );
    }
  }

  public ILink getLink( IRequestCycle iRequestCycle,
IComponent iComponent, Object[] params ){
      return this.constructLink(
iRequestCycle,getName(),null, params,false );
  }

}

--- Chris Chiappone <chiappone@gmail.com> wrote:

> To be more clear I am trying to figure out if I
> create an asset that
> is used to bring up the pdf of document.  Is that
> the way I should do
> this?
> 
> On 8/1/05, Chris Chiappone <chiappone@gmail.com>
> wrote:
> > Hi I was wonder what is the best approach when
> creating a link to a
> > blob in my db.  The blob would be a pdf or other
> type of document.
> > 
> > --
> > ~chris
> > 
> 
> 
> -- 
> ~chris
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> tapestry-user-help@jakarta.apache.org
> 
> 


Konstantin Ignatyev




PS: If this is a typical day on planet earth, humans will add fifteen million tons of carbon
to the atmosphere, destroy 115 square miles of tropical rainforest, create seventy-two miles
of desert, eliminate between forty to one hundred species, erode seventy-one million tons
of topsoil, add 2,700 tons of CFCs to the stratosphere, and increase their population by 263,000

Bowers, C.A.  The Culture of Denial:  Why the Environmental Movement Needs a Strategy for
Reforming Universities and Public Schools.  New York:  State University of New York Press,
1997: (4) (5) (p.206)

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Mime
View raw message