1

I am Using Vaadin Framework in my application. I want to open a popup screen using Vaadin Link. I know to open popup thrugh button but I need to open popup through Link. Can anybody help, this is my code:

Link link1 = new Link(String.valueOf(rs.getInt(1)), new ExternalResource("#")); 

_reportTable.getItem(dashboardDataRowId)
.getItemProperty("todo").setValue(link1);
1
  • why? because of visuals? most of the themes also have a button style, that looks like a link.
    – cfrick
    Mar 14, 2015 at 10:09

1 Answer 1

3

As explained in in Book of Vaadin - Components - Link, Link should be used only for hyperlinks to external resources, as it is nothing more than a wrapper for a anchor html tag and as such it does not fire any server side events. As a result you cannot react on server side to open a popup window or do some other logic.

The Link is a regular HTML hyperlink, that is, an anchor element that is handled natively by the browser. Unlike when clicking a Button, clicking a Link does not cause an event on the server-side.

What you really want is vaadin button styled as a hyperlink. You can do it by creating a regular button (which supoorts server side events and can open your popup) and then adding an appropriate style.

Button linkButton = new Button();
linkButton .setStyleName(BaseTheme.BUTTON_LINK);

Always be sure to call addStyleName() instead of setStyleName() as it only adds your new style to the list of other styles already present and it does not override that list with your only new style.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.