« Return to Thread: How to make img src in a component's template resolve to the image files in the package?

Re: How to make img src in a component's template resolve to the image files in the package?

by Enrique Rodriguez-2 :: Rate this Message:

Reply to Author | View in Thread

On Sun, Mar 30, 2008 at 7:45 PM, Matthew Young <ginyeah@...> wrote:
>  ...
>  I don't want to hard code
>  "/resources/com.mycompany.component.MyComponent/open.png" in the template
>  and just have <img src="open.png" .../>.  Is there someway to work out the
>  prefix "/resources/com.mycompany.component.MyComponent/" and fix up src
>  attribute in code?

If you are in a Component you can call Component#urlFor().

If not in a Component, you can call:

RequestCycle.get()#urlFor();

You can use the form that takes a ResourceReference for the image.

HTH,

Enrique

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

 « Return to Thread: How to make img src in a component's template resolve to the image files in the package?