On 01/27/10 15:57, Jonas wrote:
Have you tried the following:

WebComponent image = new WebComponent("someWicketId");
image.add(new SimpleAttributeModifier("src", "http://.....jpg";));
add(image);

with markup

<img wicket:id="someWicketId" />


that should work just fine...

if you cannot hardcode the image url, you can use the following
instead of SimpleAttributeModifier
image.add(new AttributeModifier("src", true new
AbstractReadOnlyModel<String>() {
     public String getObject() {
         String url = ... (fetch the image url from anywhere else)
         // e.g. '/xxx/yyyy/image893748.png'
         return url;
     }
));

Or, maybe a bit nicer, encapsulate it into a component and let the URI come from a Model, as usual in Wicket:

class ExternalImageUri
extends WebComponent
{
        public ExternalImageUri(String id, IModel<String> uri)
        {
                super(id, uri);
                add(new AttributeModifier("src", true, uri));
        }
                
        @Override
        protected void onComponentTag(ComponentTag tag)
        {
                super.onComponentTag(tag);
                checkComponentTag(tag, "img");
        }
}


This in the Wiki at http://cwiki.apache.org/WICKET/how-to-load-an-external-image.html.


-- Thomas


2010/1/27 François Meillet<fm...@meillet.com>:
Hi Wicketers,

I have a directory, /xxx/images with uploaded images, which is not under the 
application context root directory.
How can I serve them as static images ?

I tried the StaticImage class I found in the forum 
(http://old.nabble.com/Plain-IMG-src-urls-td21547371.html#a21547543 )
but it doesn't work for me. It just work if the image files are under the 
context root directory.

Thanks for your help.

François




---------------------------------------------------------------------
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



--
-------------------------------------------------------------------
  Thomas Kappler                        thomas.kapp...@isb-sib.ch
  Swiss Institute of Bioinformatics         Tel: +41 22 379 51 89
  CMU, rue Michel Servet 1
  1211 Geneve 4
  Switzerland                              http://www.uniprot.org
-------------------------------------------------------------------

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

Reply via email to