I am new to vaadin. I have one Link like
Link link = new Link("", new ExternalResource(redirectURL));
my requirement is, I have to set value when user clicks the link. Can I add listener when user click the link. Or is there alternate ways of setting value if link is clicked.
You could use the new BrowserWindowOpener class:
From the API:
Example:
More information here.
To capture onClick on a link or a label, I always create a
HorizontalLayout
and put the component inside it:I dint work on Vaadin yet But I looked into the document. I found that the
Link
class internally extendsAbstractComponent
class which has many functions which you can override. like it hasaddListener
function where you need to pass theComponent
listener as a parameter and can detect the click event and do whatever you want to.For reference check this
and this too
Hope this will help :)
I interpreted your question as changing the caption of the link. As far as I know it's not possibly with the Link component. Take a look at the activelink addon: http://vaadin.com/addon/activelink.
This addon behaves like Link and lets you add a
LinkActivatedListener
to it. The code should look like this: