On 9/3/2014 8:40 AM, Garret Wilson wrote:
...
I'm working around it.

Actually, my work-around doesn't work I was creating a PackageResourceReference and overriding getResource(), like this:

   item.add(new Image("icon", new PackageResourceReference(Foo.class,
   "foo-icon.png") {
      @Override
      public PackageResource getResource() {
        if (item.getModelObject().isBar()) {
          return barIconResourceReference.getResource();
        }
        return super.getResource();
      }
   }));


All my data view items get the same icon. I'm guessing PackageResourceReference.getResource() gets called once and gets cached, or something. I had assumed getResource() gets called with every render (similar isVisible()).

So for the moment I'll have to install a static PackageResourceReference up-front when creating the items in my data view.

   final ResourceReference iconResourceReference =
   item.getModelObject().isBar() ? barIconResourceReference
        : fooIconResourceReference;
   item.add(new Image("icon", iconResourceReference));


Too bad I can't have it determined dynamically.

Garret

Reply via email to