what url gets constructed? is the imageresource ever hit?

-igor

On Fri, Apr 11, 2008 at 8:34 AM, V. Jenks <[EMAIL PROTECTED]> wrote:
>
>  Sorry, I forgot to include this class, which someone here on the mailing list
>  gave to me way back in '06 when I first built this app.  It's been so long
>  since I had to look at this I forgot it was a custom class:
>
>  public class ImageResource extends DynamicWebResource
>  {
>         private ImageService imgSrv;
>
>         public ImageResource()
>         {
>                 super();
>                 imgSrv = new ImageServiceEngine();
>         }
>
>         public String getImage(String image)
>         {
>                 String retImg = null;
>
>                 try
>                 {
>                         retImg = imgSrv.getImage(image).toString();
>                 }
>                 catch (IOException exp)
>                 {
>                         LogProxy.saveEntry(exp);
>                 }
>
>                 return retImg;
>         }
>
>         protected ResourceState getResourceState()
>         {
>                 ImageResourceState state = null;
>
>                 try
>                 {
>                         ValueMap params = getParameters();
>
>                         byte[] data = null;
>                         String imageId = params.get("file").toString();
>                         //Date lastModified = getImageLastMod(imageId);
>                         state = new ImageResourceState(Time.valueOf(new 
> Date()));
>                         state.setContentType("image/gif");
>
>                         //SECURITY PRECAUTION - DO NOT ALLOW ANYTHING BUT 
> IMAGES!
>                         if 
> (imageId.contains(PropertyProxy.getExternalImagesRoot()) ||
>                                         
> imageId.contains(PropertyProxy.getExternalImagesAltRoot()))
>                         {
>                                 data = imgSrv.getImage(imageId);
>                         }
>                         else
>                         {
>                                 //change image to "not found" warning image
>                                 data = 
> imgSrv.getImage(PropertyProxy.getImageNotFound());
>
>                                 //TODO: send email to notify of inappropriate 
> access
>                         }
>
>                         state.setData(data);
>                 }
>                 catch (FileNotFoundException exp)
>                 {
>                         LogProxy.saveEntry(exp);
>                 }
>                 catch (IOException exp)
>                 {
>                         LogProxy.saveEntry(exp);
>                 }
>                 catch (NullPointerException exp)
>                 {
>                         LogProxy.saveEntry(exp);
>                 }
>
>                 return state;
>         }
>
>         /**
>          *
>          * @author vjenks
>          *
>          */
>         protected class ImageResourceState extends ResourceState
>         {
>                 private String contentType;
>                 private byte[] data;
>                 private Time lastModified;
>
>                 ImageResourceState(Time lastModified)
>                 {
>                         super();
>                         this.lastModified = lastModified;
>                 }
>
>                 public String getContentType()
>                 {
>                         return contentType;
>                 }
>
>                 void setContentType(String contentType)
>                 {
>                         this.contentType = contentType;
>                 }
>
>                 public byte[] getData()
>                 {
>                         return data;
>                 }
>
>                 void setData(byte[] data)
>                 {
>                         this.data = data;
>                 }
>
>                 public int getLength()
>                 {
>                         if (data != null)
>                                 return data.length;
>                         else
>                                 return 0;
>                 }
>
>                 public Time lastModifiedTime()
>                 {
>                         return lastModified;
>
>
>                 }
>         }
>  }
>
>
>
>  V. Jenks wrote:
>  >
>  > Hi all,
>  >
>  > I built our storefront almost two years ago now, in Wicket 1.2.x.  I'm now
>  > upgrading from 1.2.4 to 1.3 and am just about finished but I'm stuck on
>  > one seemingly simple thing.
>  >
>  > My "init()" looks like this:
>  >
>  >   public void init()
>  >   {
>  >     //create external images resource
>  >     getSharedResources().add("imageResource", new ImageResource());
>  >   }
>  >
>  > I've had this method in my own "hepler" class since this project started:
>  >
>  >       public static WebMarkupContainer getImageContainer(String name, 
> String
>  > image)
>  >       {
>  >               //get reference to Application's ResourceReference
>  >               ResourceReference imageResource = new
>  > ResourceReference("imageResource");
>  >
>  >               //build URL of image from file
>  >               String imgUrl = RequestCycle.get().urlFor(imageResource) + 
> "?file=" +
>  > image;
>  >
>  >               return getContainer(name, "src", imgUrl);
>  >       }
>  >
>  > It just encapsulates my ability to use external images in my app (outside
>  > of the deployed .ear).
>  >
>  > I would use it like so, in a Wicket page:
>  >
>  >               String thumb = 
> "C:\\MYApp\\assets\\images\\category\\Bundles.jpg";
>  >               add(WicketHelper.getImageContainer("bundleThumbImg", thumb));
>  >
>  > This always worked fine until the upgrade to 1.3 and change the filter in
>  > web.xml to look at "/*" instead of "home/*" - which I'm guessing had
>  > something to do with it?
>  >
>  > Anyhow, the images are all broken even though my path on disk is correct.
>  > Am I missing something obvious?
>  >
>  > Thanks!
>  >
>  >
>
>  --
>  View this message in context: 
> http://www.nabble.com/WebMarkupContainer---images-cannot-be-found-after-move-to-1.3--tp16627879p16627884.html
>
>
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  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