You don't *have* to use the ImageService.  You can make the
ImageResource fatter if you need.  I documented the ImageService simply
because that's what I have already and I think that using services is
generally a good idea.

On Fri, 2006-05-05 at 10:56 -0600, Vincent Jenks wrote:
> I guess I'm still a little lost here.  Why would I need to use a
> querystring to build the string?  Do I? I'm thinking not.

The ImageResource uses parameters to determine what image to pass back
to the caller.

> I'm not generating thumbnails...my version of this is much, much, much
> smaller.  I'm uploading images to a pre-defined, static location.
> That part works great, no problems there.  I'm then pulling them from
> that static location to display them. 

The thumbnails is only a happy extra.  You still need to know what
image.  Without thumbnails, you've cut back from two parameters to one.
You need a parameter that tells you which image out of that predefined
location to return.

> I know that static path on disk where the images are located and I
> know the name ahead of time (looping through a ListItem in a ListView
> from EJB3 entities in a List).
> 
> How is the id querystring param relevant?  Can't I just pass the path
> + img_name.gif into the urlFor() and be done w/ it? 
> 
> I'm probably just over-complicating this...
> 
> On 5/5/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
>         this is already described in philip's wiki article under
>         download image section 
>         
>         what you want is a stripped down version of the image
>         resource:
>         
>         public class ImageResource extends DynamicWebResource
>         {
>         
>            // CONSTANTS
>         
>            public static final Log logger = 
> LogFactory.getLog(ImageResource.class);
>         
>            private static final long serialVersionUID = 1L;
>         
>            // CONSTRUCTORS
>         
>            public ImageResource()
>         
>            {
>         
>                super();
>            }
>         
>            public ImageResource(Locale local)
>            {
>                super(local);
>            }
>         
>            // METHODS
>         
>            // MEMBERS
>         
>            @Override
>            protected ResourceState getResourceState()
>         
>         
>            {
>                ValueMap params = getParameters();
>         
>                String imageId=params.get("id");
>                byte[] data=loadImageData(id);
>                Date lastModified=
>         
>         getImageLastMod(id);
>         
>                ImageResourceState state =
>                    new ImageResourceState(Time.valueOf(lastModified));
>                state.setContentType(imageEntry.getContentType
>         
>         ());
>                state.setData(imageService.getImage(imageEntry));
>         
>                return state;
>            }
>         
>            class ImageResourceState extends ResourceState
>            {
>                // CONSTRUCTORS
>                 
>                ImageResourceState(Time lastModified)
>         
>         
>                {
>                    super();
>                    this.lastModified = lastModified;
>                }
>                 
>                // MEMBERS
>                 
>                private String contentType;
>                @Override
>                public String getContentType()
>         
>         
>                {
>                    return contentType;
>                }
>                void setContentType(String contentType)
>                {
>                    this.contentType = contentType;
>                }
>          
>                private byte[] data;
>         
>                @Override
>         
>                public byte[] getData()
>                {
>                    return data;
>                }
>                void setData(byte[] data)
>                {
>                    this.data = data;
>                }
>          
>                @Override
>         
>                public int getLength()
>         
>                {
>                    return data.length;
>                }
>          
>                private Time lastModified;
>                @Override
>                public Time lastModifiedTime()
>                {
>                    return lastModified;
>         
>                }
>         
>                  
>                // METHODS
>            }
>         }
>         then you register this as a shared resource and get a resource
>         reference. then when you want to build a url for an image you
>         do this
>         
>         ResourceReference imageResource=... 
>         String url=RequestCycle.get().urlFor(imageResource)+"?id="+id;
>         
>         hope this clears it up some more.
>         
>         -Igor
>         
>         
>         
>         hope this clears it up some more.
>         
>         
>         On 5/5/06, Vincent Jenks <[EMAIL PROTECTED]> wrote:
>                 Hi Philip,
>                 
>                 Thanks so much for the sample code and wiki entry...it
>                 makes a lot of sense, however, it is a little bit of
>                 overkill for the app I built.  You gave me a bazooka
>                 to take to a gun-fight! 
>                 
>                 Really, what it comes down to is; I need to turn the
>                 byte array I'm pulling out of the file system and turn
>                 it into an image.  The upload I already had one of my
>                 devs build was working fine and I'm not sure (for now
>                 anyways) we need your full-on image service. 
>                 
>                 I'm googling around to see if I can figure out how to
>                 simply turn the byte array into an image I can display
>                 on a page...not something I'm familiar with.  I
>                 couldn't gather from your example how this would be
>                 done, either. 
>                 
>                 Thanks for the help!
>                 
>                 
>                 On 5/2/06, Philip A. Chapman <[EMAIL PROTECTED]> wrote:
>                 
>                 How was it?  Do I need to make any edits to make it
>                 easier to understand?
>                 
>                 
>                 On Mon, 2006-05-01 at 11:28 -0600, Vincent Jenks
>                 wrote:
>                 > I'll read through this, thanks a ton!
>                 > 
>                 > On 5/1/06, Philip A. Chapman <[EMAIL PROTECTED]>
>                 > wrote:
>                 >         Sorry for the delay, but I spent the time to
>                 >         create a wiki page so that hopefully others
>                 >         can benefit from what little I have to say
>                 >         on the subject:
>                 >         
>                 >         
> http://www.wicket-wiki.org.uk/wiki/index.php/UploadDownload 
>                 >         
>                 >         
>                 >         On Mon, 2006-05-01 at 08:01 -0700, Igor
>                 >         Vaynberg wrote:
>                 >         > yes, thats it.
>                 >         > 
>                 >         > basically you would create a that resource
>                 >         > that takes the filename/fileid/whatever
>                 >         > off the url and streams the file. there is
>                 >         > an example of this, i will ask one of my
>                 >         > friends to post it here. stay tuned. 
>                 >         > 
>                 >         > -Igor
>                 >         > 
>                 >         > 
>                 >         > On 5/1/06, Vincent Jenks
>                 >         > <[EMAIL PROTECTED]> wrote:
>                 >         >         Did you mean to say
>                 >         >         DynamicWebResource?
>                 >         >         
>                 >         >         On 4/21/06, Johan Compagner
>                 >         >         <[EMAIL PROTECTED]> wrote: 
>                 >         >         > you could save those images to a
>                 >         >         DB or to a working dir on the
>                 >         >         server. 
>                 >         >         > Then have a
>                 >         >         DynamicByteArrayResource or the
>                 >         >         1.2 one: WebDynamicResource to
>                 >         >         > load the image from the location
>                 >         >         you stored the image.
>                 >         >         >
>                 >         >         > johan
>                 >         >         >
>                 >         >         >
>                 >         >         > On 4/21/06, Steve Knight <
>                 >         >         [EMAIL PROTECTED]> wrote: 
>                 >         >         > >
>                 >         >         > > I am creating a form that will
>                 >         >         allow users to upload image files
>                 >         >         that will
>                 >         >         > be displayed on other
>                 >         >         pages.  How should I go about
>                 >         >         uploading the images so 
>                 >         >         > that they can be used in Wicket
>                 >         >         Image components on the other
>                 >         >         pages?  The
>                 >         >         > upload part is not problem, I
>                 >         >         just don't know where I should put
>                 >         >         them.
>                 >         >         > >
>                 >         >         > > On my view pages, I am using
>                 >         >         ThumbnailImageResource which takes
>                 >         >         a 
>                 >         >         > WebResource in it's contructor
>                 >         >         to find the image.  Where should I
>                 >         >         save the
>                 >         >         > images to make this work?
>                 >         >         > >
>                 >         >         > > Thanks.
>                 >         >         > >
>                 >         >         > >
>                 >         >         > > Steve
>                 >         >         > >
>                 >         >         > > 
>                 >         >         > >
>                 >         >         >
>                 >         >         >
>                 >         >         
>                 >         >         
>                 >         >         
> -------------------------------------------------------
>                 >         >         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?cmdlnk&kid0709&bid&3057&dat1642
>                 >         >         
> _______________________________________________
>                 >         >         Wicket-user mailing list
>                 >         >         [email protected]
>                 >         >         
> https://lists.sourceforge.net/lists/listinfo/wicket-user 
>                 >         > 
>                 >         -- 
>                 >         Philip A. Chapman
>                 >         
>                 >         Desktop and Web Application Development:
>                 >         Java, .NET, PostgreSQL, MySQL, MSSQL
>                 >         Linux, Windows 2000, Windows XP
>                 >         
>                 >         -----BEGIN PGP SIGNATURE-----
>                 >         Version: GnuPG v1.4.1 (GNU/Linux)
>                 >         
>                 >         
> iD8DBQBEVjqCAdpynRSGw3URAiqOAKCDsSpRHf8WQ8EGaneJoAGS4WD5bwCfaYED
>                 >         Kb0kHbQYO8P7wOBWUVGWw7I=
>                 >         =x7ml
>                 >         -----END PGP SIGNATURE----- 
>                 >         
>                 >         
>                 > 
>                 -- 
>                 Philip A. Chapman
>                 
>                 Desktop and Web Application Development:
>                 Java, .NET, PostgreSQL, MySQL, MSSQL
>                 Linux, Windows 2000, Windows XP
>                 
>                 -----BEGIN PGP SIGNATURE-----
>                 Version: GnuPG v1.4.1 (GNU/Linux)
>                 
>                 
>                 
> iD8DBQBEV4M6AdpynRSGw3URAhkvAJ4tHqn2wYOd9LuuD43MWsGhnGGgxACffIoB
>                 EKdVHMEHbsM6PC+E9nkwcFw= 
>                 =GFH9
>                 -----END PGP SIGNATURE----- 
>                 
>                 
>                 
>                 
>                 
>                 
>         
>         
> 
-- 
Philip A. Chapman

Desktop and Web Application Development:
Java, .NET, PostgreSQL, MySQL, MSSQL
Linux, Windows 2000, Windows XP

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to