Why not just build yourself an 'ImageServer' component.
        Then build yourself an engine service that spits back an image and
takes a parameter.

        Have that component spit out a <img> with a url pointing back to a
custom service (make sure you encode your parameter).

        Then have your service load and feed the img in its service method?
Here's a graphic builder service I did a while ago. It's not a general case
solution, but it'll give you an idea.

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: Jelena Jovanovic [mailto:[EMAIL PROTECTED]
> Sent: Saturday, July 09, 2005 5:34 AM
> To: [email protected]
> Subject: Loading images on the fly
> 
> Hi everyone,
> 
> I need to include one or more images in a page
> that is dynamically created. Which images should
> be included in the page is determined during the
> runtime. Images that I work with are kept in a
> subdirectory of the context directory. However,
> the images collection is rather large and can
> increase during the program execution, so I can
> not enumerate those images as assets in the .page
> file. I saw that there are some classes that
> implement IAsset interface and I guess that I
> should use one of them, but I do not know how. Can
> anyone send a piece of code showing how to handle
> this problem?
> 
> 
> Regards,
> 
> Jelena
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to