You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Paul Russell <pa...@luminas.co.uk> on 2006/10/11 23:01:19 UTC

Image component: accepting ResourceReferences from the Model

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.

Re: Image component: accepting ResourceReferences from the Model

Posted by Eelco Hillenius <ee...@gmail.com>.
Cheers, we'll look into it.

Eelco


On 10/13/06, Paul Russell <p....@sourcesense.com> wrote:
> Guys,
>
> On 11 Oct 2006, at 22:01, Paul Russell wrote:
> > [...] 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. [...]
>
> I've added a patch (only against the wicket-1.x branch right now -- I
> will forward port it to the trunk next week) to the issue tracker on
> SF for this.
>
> Thanks,
>
>
> Paul
>

Re: Image component: accepting ResourceReferences from the Model

Posted by Paul Russell <p....@sourcesense.com>.
Guys,

On 11 Oct 2006, at 22:01, Paul Russell wrote:
> [...] 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. [...]

I've added a patch (only against the wicket-1.x branch right now -- I  
will forward port it to the trunk next week) to the issue tracker on  
SF for this.

Thanks,


Paul