wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sven Meier <s...@meiers.net>
Subject Re: How to hide an optional Image component?
Date Tue, 16 Jul 2013 21:00:46 GMT
> apart from asking the database _again_ for the data or presence thereof

Whether the image is visible must be determined when the page is rendered. The actual loading
of the image is done in another request. Thus two times to ask the databse.

Alternatively you may render a default resource (e.g. https://www.google.com/search?q=no+image)
if your database doesn't have any data to stream back when the image is requested.

Regards
Sven


On 07/16/2013 10:53 PM, Stefan Renz wrote:
> Hi guys,
>
> I'm desparate for your help: I just can't figure out how to suppress an
> Image in case its IResource yields nothing.
>
> Here's some context:
>
> A customer may have a custom logo image (in fact, there's some logic
> involved in determining which exact logo to use, but that's beside the
> point) located in some database. Using Wicket's Image component, I
> figured I would need to implement the logo resolution algorithm and
> loading from the DB with either subclassing DynamicImageResource, or
> subclassing AbstractResourceStream (which is more approriate?).
>
> Works fine if a logo is there -- the image shows up. However, if there
> _is_ no logo, the browser (firefox in my case) renders a question mark
> instead of showing nothing. Both returning null or an empty byte array
> doesn't matter.
>
> I usually suppress a component with a behavior, or within the
> #onConfigure()-Method, but in the Image's case, where I only have an
> IResource or ResourceReference, I just don't have a hint on how to
> determine if the image data is there or not (apart from asking the
> database _again_ for the data or presence thereof).
>
> Any ideas? What method/class have I missed? Where should I look?
>
> Thanks for your help.
> Cheers
>      Stefan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Mime
View raw message