Worked great. What I did:

1) Created the FileResource class:

public class FileResource extends WebResource {
    private static final long serialVersionUID = 1L;

    private File file;
    
    public FileResource(File file) {
        this.file = file;
    }
    
    @Override
    public IResourceStream getResourceStream() {
        return new FileResourceStream(file);
    }
}


2) In MyPage.java:

File imageFile = new File("local_path_to_image");
Image myImage = new Image("myImage", new FileResource(imageFile));
add(myImage);


3) In MyPage.html:

<i-m-g wicket:id="myImage" />



igor.vaynberg wrote:
> 
> you can use a shared resource to do this, there is a page on the wiki
> somewhere. you can also look at wicket pastebin project on berlios
> repo.
> 
> a simpler (but thread-blocking) way is to see how downloadlink does it.
> 
> -igor
> 
> On Tue, May 20, 2008 at 8:04 AM, Blackbird <[EMAIL PROTECTED]> wrote:
>>
>> Hi, I have a repository storing many images somewhere on the server. The
>> hierarchy is like : C:\Images\YYYY\MM\DD.jpg
>> I want to be able to create a dynamic Image object (or ContextImage or
>> whatever works with <i-m-g wicket:id="fooImage" />) with one of the
>> images
>> stored in my repository.
>> I can't figure out how to do it, can someone help?
>> --
>> View this message in context:
>> http://www.nabble.com/Creating-Image-from-local-directory-outside-project-tp17342679p17342679.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]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Creating-Image-from-local-directory-outside-project-tp17342679p17359927.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]

Reply via email to