link event listener

  1. Is there a way to add a click listener to a link component??
  2. Is there a way to handle a javascript event like mouseover mouseclick etc ???

Are they above implemented through the use of addListener methods of Component/AbstractComponent, can someone plz give an example???

Any help would be much appreciated, thanks in advance!!

Here is a simple demo:


http://uilder.virtuallypreinstalled.com/run/LinkTest/


Button b = new Button("This is an active link");
b.setStyleName("link"); 
_l.addComponent(b);

b.addListener(new Button.ClickListener() {
	public void buttonClick(Button.ClickEvent event) {
		_w.showNotification("Clicked");
	}
});

Thanks a lot for the fast response. :smiley:

I was aware of the button with the style link, however i would like to use an actual html link hence the Link component in order to take advantage of actions related to html links i.e. the open in new tab functionality in browsers. At that point i got curious about the javascript events, whether they can be handled by the framework…

I see. Then this could be what you are looking for
http://dev.vaadin.com/svn/versions/6.1/src/com/vaadin/demo/sampler/ActiveLink.java

See also the client-side implementation:
http://dev.vaadin.com/svn/versions/6.1/src/com/vaadin/demo/sampler/gwt/client/ui/VActiveLink.java

Great this is what I was looking for.

  1. So if there is a need for javascript events to be handled new custom component will have to be made… right??

  2. So how can i import this component (ActiveLink) to my project? Should i follow the custom component procedure described in vaadin book (ch.9)?

Thank you very much!!

Right. Good side is that creating custom components is really really easy. Just browse thought chapter 10: creating custom components in the new edition of vaadin book:
http://dev.vaadin.com/svn/doc/trunk/manual/book-pocket.pdf

Basically just: 1) create a component in eclipse wizard, 2) select exiting component to extend, 3) write your additions to generated component stub.

In future there could also be possibility to catch client-side events from server-side. Recently got a contribution for this feature:
http://dev.vaadin.com/ticket/3234

Yes.

You should take a look of the new book edition (linked above) the chapter has many useful additions.

Thank you very much!! :slight_smile:
I really appreciate your help and fast responses!!
Btw, congratulations the framework is really great !!

I found it as an add-on:
https://vaadin.com/directory#addon/activelink

After getting add-on activelink, it make this error:
[ERROR]
Errors in ‘org/vaadin/activelink/client/ui/ActiveLinkConnector.java’
[INFO]
[ERROR]
Line 36: The method updateFromUIDL(UIDL, ApplicationConnection) is undefined for the type LinkConnector
[INFO]
[ERROR]
Aborting compile due to errors in some input files

Any help would be appreciate