tags:

views:

215

answers:

2

I am just wondering how I can specify a dynamic url for an image src in apache wicket. I just thought about something like new StaticResourceReference("images/buttons/" + filename+ ".gif") but I cannot find such a class or apporoach. There seem to be ugly workarounds, like the ones mentioned here.

I really can't imagine that a popular framework like wicket doesn't have an easy support for dynamic relative/absolute urls (also think about external ressources/urls..)

Did I missed something? Thank you!

+1  A: 

If you just want a dynamic filename, try something like this:

html:

<img wicket:id="wicketimage"/>

code to support your html page:

WebMarkupContainer markup = new WebMarkupContainer( "wicketimage" );
markup.add( new AttributeModifier( "src", true, new Model<String>( "images/buttons/filename.gif" ) ) );    
add( markup );
Alex B
A: 

This document describes two possiblities how to do it in wicket: I am not 100% happy with the approaches, but it seems to work.

MRalwasser