You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by wfaler <wi...@gmail.com> on 2007/09/27 17:36:49 UTC

Changing html-template programmatically?

Hi,
Is it possible to change the default html-template file loaded for a class
programmatically (for instance, changing from a classpath file, to a file in
another file-directory)?
For instance, if I want to change the underlying html-template on the fly,
but keeping the same component hierarchy?

Regards
Wille
-- 
View this message in context: http://www.nabble.com/Changing-html-template-programmatically--tf4529206.html#a12923955
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: Changing html-template programmatically?

Posted by Matthijs Wensveen <m....@func.nl>.
wfaler wrote:
> Hi,
> Is it possible to change the default html-template file loaded for a class
> programmatically (for instance, changing from a classpath file, to a file in
> another file-directory)?
> For instance, if I want to change the underlying html-template on the fly,
> but keeping the same component hierarchy?
>
> Regards
> Wille
>   
Hi Wille,

You can implement IResourceStreamLocator and set an instance of that on 
your application: 
myApplication.getResouceSettings().setResourceStreamLocator(myResourceStreamLocator);

You can then return an IResourceStream from any source you might have 
(another directory, a database, anything)
A nifty trick (I think) is to use the locator that is already set on the 
application to fall back to when your locator can't find the requested 
resource, but that is up to you and your requirements.

When you don't want to set a IResourceStreamLocator globally, but just 
for a component, you can have that component implement 
IMarkupResourceStreamProvider (and preferably also 
IMarkupCacheKeyProvider). This way you can return a desired 
IResourceStream based on some model property if you like.

Be careful that you do add the required components to your hierarchy. 
This is especially true when you generate markup dynamically.
Also, take a look at the custom template / resource loading examples at: 
http://wicketstuff.org/wicket13/customresourceloading/

BTW, does anyone know what the purpose of 
application.getResourceSettings().getResourceFinder() is?

Regards,
Matthijs

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