Button that acts as a direct link?

Hello all,

my app contains a row of buttons. One of the buttons opens an external link in a new window. Currently, this is behaviour is implemented by a ClickListener that calls Window.open() with an external resource. However, this approach usually leads to problems with popup blockers: popups must be explicitly enabled for the site and, depending on the browser being used, the reason why the popup did not appear is not always obvious to the user. To make matters worse, the popup functionality does not appear to work in IE 8 even if the popup blocker is disabled.

Popup blockers usually do not interfere with windows that are opened by clicking on direct links. So, would it be possible to wrap the button in tags that open the popup directly? Any help with this issue would be greatly appreciated.

Regards,
Philip

Use a label

Label label = new Label("<a href=\"http://vaadin.com\">Vaadin</a>", Label.CONTENT_XHTML);
// A label is by default 100% wide, so you might need/want to do this
label.setWidth(null);

Hi Kim,

thanks for your response. For the sake of appearance I do not want a label in the middle of the row of buttons. Is it possible to style a label so that it looks like a button? So, what I need is either a button wrapped in tags, or a label styled to look like a button.

Regards,
Philip

Try this.

Label label = new Label("<div class=\"v-button\"><span class=\"v-button-wrap\"><a href=\"http://vaadin.com\" class=\"v-button-caption\">Vaadin</a></div></div>", Label.CONTENT_XHTML);
label.setWidth(null);

Works great, thanks Jouni!