Hi guys,

I came unstuck yesterday at work while implementing a simple Panel- based component which contained an image which was dynamically selected from a list of static images held as ResourceReferences.

My mistake was assuming that I could use a PropertyModel to extract and return the ResourceReference and return it directly, and have the image render it. The results of that were that the LocalizedImageResource did getModelAsString on the Image, which in turn did a toString on the ResourceReference. When the LocalizedImageResource tried to load the resource, it unfortunately gave a plausible looking error message stating that it couldn't load what looked (due to the toString) like a perfectly valid resource. After about an hour and a half of head scratching, I realised that I just needed to override the getImageResourceReference() method on Image to achieve the desired effect.

Now, to the meat of my question, and apologies if I'm covering old ground here. How do you guys feel about modifying Image (or more likely LocalizedImageResource) so that it supports Models containing both ResourceReferences and Resources? I can't see that this could break anything, as I can't see how someone could legitimately want to be trying to load a resource that's a result of Resource.toString()!! I would welcome the chance to do the work to make this happen (other than committing, obviously -- I assume the appropriate route is to raise an issue at SF and attach a patch?), but wanted to check that I'm not missing a glaring reason why this can't or shouldn't be implemented. If there is a glaring reason why it shouldn't be implemented, can I suggest that I wordsmith some additional JavaDoc for the Image class to make the getImageResourceReference/ getImageResource design pattern clear?

Thanks,


P.

Reply via email to