You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Scott F. Walter" <sc...@vivare.com> on 2005/08/05 16:09:05 UTC
Binary Content Service?
Before I get started to write one, has anybody created a generi bnary
content Tapestry service? This way I can have on ustom Tapestry service
that can handle downloading pdfs, images, etc.
scott.
--
Scott F. Walter Scott F. Walter
Principal Consultant
Vivare, Inc.
E: scott.walter@vivare.com
E: scott@scottwalter.com
Visit scottwalter.com <http://scottwalter.com> --Point. Click. Explore!
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: Binary Content Service?
Posted by Patrick Casey <pa...@adelphia.net>.
This might be what you're looking for.
package services;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import org.apache.tapestry.IComponent;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.engine.AbstractService;
import org.apache.tapestry.engine.IEngineServiceView;
import org.apache.tapestry.engine.ILink;
import org.apache.tapestry.request.ResponseOutputStream;
import processmodel.ProcessDescription;
import data.HibHelper;
public class GraphicBuilder extends AbstractService {
public static final String SERVICE_NAME = "GraphicBuilder";
public ILink getLink(IRequestCycle cycle, IComponent component,
Object[] parms) {
String[] context;
String pageName = component.getPage().getPageName();
String idPath = component.getIdPath();
if (idPath != null) {
context = new String[2];
context[1] = idPath;
} else
context = new String[1];
context[0] = pageName;
return constructLink(cycle, SERVICE_NAME, context, parms,
true);
}
public void service(IEngineServiceView acrg0, IRequestCycle cycle,
ResponseOutputStream response) throws
ServletException, IOException {
Object[] parms = this.getParameters(cycle);
String id = (String) parms[0];
ProcessDescription pd = (ProcessDescription)
HibHelper.getSession().get(ProcessDescription.class, id);
BufferedImage bufferedImage = pd.toGraphic();
response.setContentType("image/png");
synchronized (this) {
ImageIO.write(bufferedImage, "png", response);
}
}
public String getName() {
return SERVICE_NAME;
}
}
> -----Original Message-----
> From: Scott F. Walter [mailto:scott.walter@vivare.com]
> Sent: Friday, August 05, 2005 10:38 AM
> To: Tapestry users
> Subject: Re: Binary Content Service?
>
> Patrick Casey wrote:
>
> > I don't know that you need a custom service for this, do you? You
> >can just use a directlink and feed binary data directly into the response
> >stream, neh?
> >
> > Something like this (from my attachment rendering code):
> >
> >public void trigger(IRequestCycle cycle) {
> > Object[] args = cycle.getServiceParameters();
> > String id = (String) args[0];
> > Session s = HibHelper.getSession();
> > Attachment at = (Attachment)
> >s.get(attachment.Attachment.class, id);
> > try {
> > HttpServletResponse r =
> >cycle.getRequestContext().getResponse();
> > r.setContentLength((int) at.getLength());
> > r.setHeader("Content-Disposition", "attachment;
> >filename=" + at.getFileName());
> > r.getOutputStream().write(at.getDetail().getData());
> > } catch (Exception e) {
> > Log.error(e);
> > }
> >
> > }
> >
> >
> >
> >>-----Original Message-----
> >>From: Scott F. Walter [mailto:scott.walter@vivare.com]
> >>Sent: Friday, August 05, 2005 7:09 AM
> >>To: Tapestry users
> >>Subject: Binary Content Service?
> >>
> >>Before I get started to write one, has anybody created a generi bnary
> >>content Tapestry service? This way I can have on ustom Tapestry service
> >>that can handle downloading pdfs, images, etc.
> >>
> >>scott.
> >>--
> >>
> >>Scott F. Walter Scott F. Walter
> >>Principal Consultant
> >>Vivare, Inc.
> >>
> >>E: scott.walter@vivare.com
> >>E: scott@scottwalter.com
> >>Visit scottwalter.com <http://scottwalter.com> --Point. Click.
> Explore!
> >>
> >>
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >>
> >>
> >
> >
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
> >
> >
> I guess I wasn't clear enough. I want the binary content to be on the
> page. For example a thumbnail contact sheet where the thumbnails are
> dynamically generated.
>
> scott.
>
> --
>
> Scott F. Walter Scott F. Walter
> Principal Consultant
> Vivare, Inc.
>
> E: scott.walter@vivare.com
> E: scott@scottwalter.com
> Visit scottwalter.com <http://scottwalter.com> --Point. Click. Explore!
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Binary Content Service?
Posted by "Scott F. Walter" <sc...@vivare.com>.
Patrick Casey wrote:
> I don't know that you need a custom service for this, do you? You
>can just use a directlink and feed binary data directly into the response
>stream, neh?
>
> Something like this (from my attachment rendering code):
>
>public void trigger(IRequestCycle cycle) {
> Object[] args = cycle.getServiceParameters();
> String id = (String) args[0];
> Session s = HibHelper.getSession();
> Attachment at = (Attachment)
>s.get(attachment.Attachment.class, id);
> try {
> HttpServletResponse r =
>cycle.getRequestContext().getResponse();
> r.setContentLength((int) at.getLength());
> r.setHeader("Content-Disposition", "attachment;
>filename=" + at.getFileName());
> r.getOutputStream().write(at.getDetail().getData());
> } catch (Exception e) {
> Log.error(e);
> }
>
> }
>
>
>
>>-----Original Message-----
>>From: Scott F. Walter [mailto:scott.walter@vivare.com]
>>Sent: Friday, August 05, 2005 7:09 AM
>>To: Tapestry users
>>Subject: Binary Content Service?
>>
>>Before I get started to write one, has anybody created a generi bnary
>>content Tapestry service? This way I can have on ustom Tapestry service
>>that can handle downloading pdfs, images, etc.
>>
>>scott.
>>--
>>
>>Scott F. Walter Scott F. Walter
>>Principal Consultant
>>Vivare, Inc.
>>
>>E: scott.walter@vivare.com
>>E: scott@scottwalter.com
>>Visit scottwalter.com <http://scottwalter.com> --Point. Click. Explore!
>>
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>
>
>
I guess I wasn't clear enough. I want the binary content to be on the
page. For example a thumbnail contact sheet where the thumbnails are
dynamically generated.
scott.
--
Scott F. Walter Scott F. Walter
Principal Consultant
Vivare, Inc.
E: scott.walter@vivare.com
E: scott@scottwalter.com
Visit scottwalter.com <http://scottwalter.com> --Point. Click. Explore!
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: Binary Content Service?
Posted by Patrick Casey <pa...@adelphia.net>.
I don't know that you need a custom service for this, do you? You
can just use a directlink and feed binary data directly into the response
stream, neh?
Something like this (from my attachment rendering code):
public void trigger(IRequestCycle cycle) {
Object[] args = cycle.getServiceParameters();
String id = (String) args[0];
Session s = HibHelper.getSession();
Attachment at = (Attachment)
s.get(attachment.Attachment.class, id);
try {
HttpServletResponse r =
cycle.getRequestContext().getResponse();
r.setContentLength((int) at.getLength());
r.setHeader("Content-Disposition", "attachment;
filename=" + at.getFileName());
r.getOutputStream().write(at.getDetail().getData());
} catch (Exception e) {
Log.error(e);
}
}
> -----Original Message-----
> From: Scott F. Walter [mailto:scott.walter@vivare.com]
> Sent: Friday, August 05, 2005 7:09 AM
> To: Tapestry users
> Subject: Binary Content Service?
>
> Before I get started to write one, has anybody created a generi bnary
> content Tapestry service? This way I can have on ustom Tapestry service
> that can handle downloading pdfs, images, etc.
>
> scott.
> --
>
> Scott F. Walter Scott F. Walter
> Principal Consultant
> Vivare, Inc.
>
> E: scott.walter@vivare.com
> E: scott@scottwalter.com
> Visit scottwalter.com <http://scottwalter.com> --Point. Click. Explore!
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org