[ 
https://issues.apache.org/jira/browse/WICKET-4718?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437758#comment-13437758
 ] 

Carsten Dräger edited comment on WICKET-4718 at 8/20/12 8:17 PM:
-----------------------------------------------------------------

Thank you for your comment! Unfortunately, I already tried both, and there's 
two problems with it.

1) Can't do that, because that would make my resources static. I'm having many 
different ResourceLinks on one page, if I would load all those resources at 
once at page-load I would have a horrible performance. I also need to create 
the ResourceLink at page-load because I need the URL for it (it's not supposed 
to be a shared resource, my site is secured) to pass it to other functions, 
e.g. a JW Player for a mp3-file coming from the database.

2) I tried to cache the stream with a class variable in #getResourceStream(), 
but I also couldn't do that because the org.ektorp.AttachmentInputStream is not 
serializable. I get an error if I do that, the page can't be serialized and I 
don't have access to the resource even though it apparently has been queried 
once.

So 1) is not an option for now. Do you maybe see a solution to point 2?
                
      was (Author: blacklight):
    Thank you for your comment! Unfortunately, I already tried both, and 
there's two problems with it.

1) Can't do that, because that would make my resources static. I'm having many 
different ResourceLinks on one page, if I would load all those resources at 
once at page-load I would have a horrible performance. I also need to create 
the ResourceLink at page-load because I need to URL for it (it's not supposed 
to be a shared resource, my site is secured) to pass it to other functions, 
e.g. a JW Player for a mp3-file coming from the database.

2) I tried to cache the stream with a class variable in #getResourceStream(), 
but I also couldn't do that because the org.ektorp.AttachmentInputStream is not 
serializable. I get an error if I do that, the page can't be serialized and I 
don't have access to the resource even though it apparently has been queried 
once.

So 1) is not an option for now. Do you maybe see a solution to point 2?
                  
> ResourceStreamResource#getResourceStream() is called multiple times
> -------------------------------------------------------------------
>
>                 Key: WICKET-4718
>                 URL: https://issues.apache.org/jira/browse/WICKET-4718
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 6.0.0-beta3
>         Environment: Mac OS X 10.7.4 Lion, Java 6, IntelliJ Idea 11.1, Tomcat 
> 7 & Jetty 7.5.0
>            Reporter: Carsten Dräger
>
> When a ResourceStreamResource is implemented to return a IResourceStream 
> dynamically, by returning a new instance of an extended 
> AbstractResourceStream, that ResourceStream is instantiated multiple times 
> when a ResourceLink is clicked.
> In my case, that ResourceStream returns an AttachmentInputStream from the 
> Ektorp library (for CouchDB interaction). This behavior results in multiple 
> queries (currently up to four) when I click once on a ResourceLink to that 
> resource.
> Code Examples
> Extended ResourceStreamResource: http://pastebin.com/9BB7LEiV
> Extended IResouceStream: http://pastebin.com/Z7GvzGja

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


Reply via email to