Wicket rewrite the SRC attribute of the image as relative to your webapp 
context unless you declare that image as a wicket component, give it a 
wicket:id and then use a ContextImage.

Thus you would turn a <img src="../images/image.jpg"> to a <img wicket:id="img" 
src="../images/image.jpg">.

If you do so, then you can still preserve the "wrong" src relative path of 
"../images/image.jpg" so that your web developers can see the images while 
editing the static HTML resources and when you run the web-app Wicket will take 
care of fixing that URL for you no matter at what point you mount the page.

If you have too many such images and refactoring might take you too long, then 
consider write your own Custom Wicket Tag Resolver for an attribute of the img 
HTML tag and override what the framework does for you (do call super) by 
changing the src attribute in a similar way ContextImage would do it for you.

For example see this article:
http://sanityresort.blogspot.com/2011/08/creating-custom-wicket-tag-resolver.html

Or see how other such resolvers or AttributeModifer are used by Wicket itself, 
you can start with the AutoComponentResolver.

~ Good look to you!
  Paul Bors

-----Original Message-----
From: Joachim Schrod [mailto:jsch...@acm.org] 
Sent: Tuesday, August 14, 2012 2:53 AM
To: users@wicket.apache.org
Subject: Re: How to control IMG/CSS URL-Rewriting in mounted pages?

Yes, that's what I observed and described below. And that behavior is not 
appropriate for my use case.

So, how can I stop Wicket to "make the url relative to the web root no matter 
what mount path I use for the page"?

I want to *change* that: my designer delivers HTML where the images are *not* 
relative to the web root, but to one directory below. In our HTML files are 
URLs like "../images/image.img" and I don't want to change these URLs.

Alternatively, how can I tell Wicket that the web root has a different prefix 
just for rewriting these image URLs?

Thanks,
Joachim

Martin Grigorov wrote:
> Hi,
> 
> If your images/css are in the web root then use something like 
> "images/image.img" in your .html.
> Wicket will make the url relative to the web root no matter what mount 
> path you use for the page.
> 
> On Mon, Aug 13, 2012 at 5:41 PM, Joachim Schrod <jsch...@acm.org> wrote:
>> Hi,
>>
>> I'm new to Wicket and write my first application in it. I use "Wicket 
>> in Action" and online resources as documentation. (I stumbled already 
>> about the 1st few roadblocks owing to changes from Wicket 1.4 to 1.5. 
>> ;-)) So, if there's an easy pointer to answer my question, don't 
>> hesitate to just send it.
>>
>> My problem: I have a page that's mounted as URL "cat/entry". In the 
>> page's HTML there are links to images and CSS files that start with 
>> "..", e.g., "../images/bg_blabla.img". These are no Wicket 
>> components, just plain HTML.
>>
>> When Wicket renders the page, it rewrites the image URLs and prepends 
>> "../", e.g., the image URL now is output as 
>> "../../images/bg_blabla.img". I suppose it tries to adept to the 
>> extra path level that I introduced during mount and compensates for it.
>>
>> How can I stop Wicket from adding this "../" prefix? I searched via 
>> Google and read through Javadocs, but to no avail.
>>
>> For background: The URL in the HTML file is right... My HTML 
>> designers deliver their design files as "cat/entry.html", my mounts 
>> just follow their lead. I would like to change their files as little 
>> as possible, it makes files swapping back to/with them much easier.
>>
>> I hope somebody here may help me, thanks in advance.
>>
>>         Joachim

--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Joachim Schrod, Roedermark, Germany
Email: jsch...@acm.org


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



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

Reply via email to