sounds like what you need is to stream the file to the output stream when the browser requests the image.

easiest way to do this imho is the following (pseudocode)

/** resource that can read a file given a name */
class FileResource extends Resource {
  private final String pathToFile;

  public FileResouce(String pathToFile) { this.pathToFile=pathToFile; }

  IResourceStream getResourceStream() {
         return new IResouceStream() {
              int length() { return new File(pathToFile).size(); }
              InputStream getInputStream() { return new FileInputStream(pathToFile); }
             ...
}

so now you have a resource that can stream a file off disk - now to stream it just do

add(new Image("myimage", new FileResource("/tmp/myfile.gif")));

not sure if it fits your usecase exactly - this is not for throw away images. if this is not what you need can you define your usecase better.

if it is what you need mind making a wiki page after you get it working? :)


-Igor


 

On 8/27/06, Brian Glynn < [EMAIL PROTECTED]> wrote:

I've been pouring over the documentation last few days trying to figure out how to use dynamically created images in my application, with no luck.

 

Here's a little background: The image is created by supplying a directory path, getWicketServlet().getServletContext().getRealPath("/tmp")  in this case, to the image creation method. The method then returns base file name of the newly created image (example: foo123.png).  I have verified that the images are being created in the supplied directory, but I'm not sure how or the preferred way of getting them in the application

 

I've tried adding the folder location to the getResourceSettings().addResourceFolder(path) and then passing the base name to the Image component. This seems like the ideal solution, but by looking at the error page it seems that the addResourceFolder() goes unnoticed and as the page only shows current class package directory (/com/something/foo123.png) as been searched for the image. I've also tried using a ResourceReference new Image("img", new ResourceReference(path+name)), but it never seems to find the right location of the image.

 

I am able to use the images by sub classing DynamicImageResource and reading a File object of the image to a byte[] in the getImageData() method, but that seems like overkill and clunky. There has to be a way to just specify a url or path in the Image component, doesn't there? I'm clearly missing something.

 

Thank you very much for your help,

 

Brian

 

           


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.6/428 - Release Date: 8/25/2006


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to