You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Jonas (JIRA)" <ji...@apache.org> on 2016/07/06 08:11:10 UTC

[jira] [Commented] (WICKET-6195) ResourceMapper / ImageResourceReferences not working as expected

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

Jonas commented on WICKET-6195:
-------------------------------

Hi Patrick

We had similar problems and were able to solve them by extending ResourceStreamResource instead of DynamicImageResource: ResourceStreamResource properly handles all caching, mime type, etc. Applied to your case, DynamicPersonImageResource would look something like this (haven't tested it, but thats more or less what we do in our webapp):

public class DynamicPersonImageResource extends ResourceStreamResource {

  private static final Duration TEN_HOURS = Duration.hours(10);
  
  public DynamicPersonImageResource() {
    super();
    setCacheDuration(TEN_HOURS);
  }
  
  @Override
  protected IResourceStream getResourceStream() {
    PackageResourceReference imageReference = new PackageResourceReference(DynamicPersonImageResource.class, "person.png");
    return imageReference.getResource().getResourceStream();
  }

}

cheers,
Jonas


> ResourceMapper / ImageResourceReferences not working as expected
> ----------------------------------------------------------------
>
>                 Key: WICKET-6195
>                 URL: https://issues.apache.org/jira/browse/WICKET-6195
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 6.22.0
>            Reporter: Patrick Davids
>         Attachments: imgres.zip
>
>
> Hi,
> as discussed in
> https://www.mail-archive.com/users@wicket.apache.org/msg89246.html
> It seems the ResourceMapper is not working as expected by tutorial:
> http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/
> ??The override of #equals() is the second requirement needed by ResourceMapper to fully recognize the mapped resource.??
> \\
> _equals()_ is never called by wicket and _getResource()_ is always called, returning a new instance.
> This is why I loose my lastModified information and always gets HTTP 200.
> When having a static instance of image resource in the image resource reference; always returning the same instance when getResource() is called it is working (get HTTP 304).
> See quickstart attached...
> kind regards
> Patrick



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)