hudi
hudi

Reputation: 16525

How to return link to an external URL in Wicket?

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?

Upvotes: 4

Views: 6319

Answers (2)

jordeu
jordeu

Reputation: 6821

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)

Upvotes: 8

magomi
magomi

Reputation: 6685

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);
...

Upvotes: 3

Related Questions