How to return link to an external URL in Wicket?

こ雲淡風輕ζ 提交于 2019-12-12 12:03:09

问题


I have a web application with form. When I click to save, application creates some file and returns some url. How I can display this url to web page?


回答1:


Use ExternalLink.

A normal static link:

new ExternalLink("link", "http://some.url", "This is a some.url link");

Depending on the context may be better to use this other constructor that admits and IModel of your href and label parameters:

ExternalLink(final String id, final IModel<String> href, final IModel<?> label)



回答2:


One way is to simply create a Link and override the onComponentTag method:

The html part:

...
<a wicket:id="link">[link]</a>
...

The java part:

...
Link link = new Link("link") {
    @Override
    protected void onComponentTag(ComponentTag tag) {
        tag.put("href", "http://www.example.com/");
    }
};
add(link);
...


来源:https://stackoverflow.com/questions/10210908/how-to-return-link-to-an-external-url-in-wicket

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!