you can't do that because that will also prefix the wicket servlet path. So you just need to append the context path only
you can get the context path by:
String contextPath = Application.get().getApplicationSettings().getContextPath();
so if you prepend that to your url:
/contextpath/mage/logo/xxxx
it should work.
johan
On 9/20/06, x商J?$ b�UM}扫yH? <[EMAIL PROTECTED]> wrote:
Hello!
I have try to use wicket and found this is a good framework.
But I found some problem and need help.
There are some images in a folder and the images are named 0.jpg, 1.jpg, 2.jpg and so on.
I need to show random image on a page. But the folder not in the /WEB-INF/classes.
If use JSP, I will write code like this:
<img src="" "image/logo/"+ Math.abs((new Random).nextInt(3))) + ".jpg")) %>" />
and the tag will show as <img src="" />.
I have read the code of image example and I found wicket not supply this function.
I write a class to do this.
public class ImageLabel extends WebComponent {
private static final long serialVersionUID = 1L;
public ImageLabel(String id, Model model) {
super(id,model);
}
@Override
public void onComponentTag(final ComponentTag tag)
{
checkComponentTag(tag, "img");
super.onComponentTag(tag);
tag.put("src", getModelObjectAsString());
}
}
the java code
add(new ImageLabel("logo", new Model("image/logo/"+ Math.abs((new Random).nextInt(3))) + ".jpg")));
the html
<img wicket:id="logo" />
I create a context called "WicketStudy",
if the url is " http://localhost/WicketStudy/", it works good.
But if the url is "http://localhost/WicketStudy " or append some parameter,
the image can't show because the relative url is error.
I have read the package wicket.markup.html.image, but can't find the which class can do this.
How can I do to handle this problem?
Thank you for read my e-mail.
===============================================
快来和我一起享受TOM免费邮箱吧! 看看除了1.5G,还有什么?![]()
敲开精彩 聊天世界:网通用户 电信用户
明星金曲免费送(http://mm.tom.com/ivr/): 周杰伦 林俊杰 庞龙 张惠妹
劲爆歌曲尽情点(http://mm.tom.com/ivr/): 霍元甲 吉祥三宝 人质 曹操
炫酷彩铃免费送(http://mm.tom.com/cailing/): 周杰伦帮你接电话 麻烦女朋友 七里香 小城故事
===============================================
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Wicket-user mailing list Wicket-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wicket-user