James Carman wrote:
I don't know that I would cache the image data.  That will get stored
in the session.  Why use a DynamicImageResource if you're going to
cache (store it in a member variable) the image data anyway?
Well, sure.. And it's not cluster safe.. There are pros and cons to it... As with everything..
  If the
data comes from the database, then look it up when the resource is
requested.
On Sun, Oct 19, 2008 at 4:42 AM, Nino Saturnino Martinez Vazquez Wael
<[EMAIL PROTECTED]> wrote:
Search the forum:)

http://markmail.org/message/hgkugvqm6x2hj3j5#query:wicket%20image%20webresource+page:1+mid:hgkugvqm6x2hj3j5+state:results


You could also just inject the provider and serve it if not loaded, eg the
method above + injection, I think thats the best option, as it should be
cluster safe..

or this:

package zeuzgroup.application.utils;

import java.awt.image.BufferedImage;

import org.apache.wicket.markup.html.image.resource.DynamicImageResource;

public class ImageResource extends DynamicImageResource {

  // has to save this. or get the image another way!
  private byte[] image;

  public ImageResource(byte[] image, String format) {
      this.image = image;
      setFormat(format);
  }

  public ImageResource(BufferedImage image) {
      this.image = toImageData(image);
  }

  @Override
  protected byte[] getImageData() {
      if (image != null) {
          return image;
      } else {
          return new byte[0];
      }

  }

  /**
   * 1 day!
   */
  @Override
  protected int getCacheDuration() {
            return 3600*24;
  }

}


shrimpywu wrote:
hi, i want to upload a image from wicket and store it into dabase, how can
i
display it?

in hibernate, i define the type as  Blob to store the image,
however, when i try to read it,
get the input stream from blob

it always complain that after serialzation, blog may not be asscessable.

/////
item.add(new Image("imgItem", new Resource() {

                       @Override
                       public IResourceStream getResourceStream() {
                           return new AbstractResourceStream() {

                               public InputStream getInputStream() throws
ResourceStreamNotFoundException {
                                                      return
blob.getBinaryInputStream();
                                                        }

                               public void close() throws IOException {
                                   // close input stream
                               }
                           };
                       }
                   }) );

////

can anybody give me any suggestion,

Thanks.....

--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


---------------------------------------------------------------------
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]


--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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

Reply via email to