
The basic form of interaction offered by web applications is to navigate through pages using links. In HTML a link is basically a pointer to another resource that most of the time is another page. Wicket implements links with component _org.apache.wicket.markup.html.link.Link_, but due to the component-oriented nature of the framework, this component is quite different from classic HTML links.  
Following the analogy with GUI frameworks, we can consider Wicket link as a “click” event handler: its purpose is to perform some actions (on server side!) when the user clicks on it.

That said, you shouldn't be surprised to find an abstract method called _onClick()_ inside the _Link_ class. In the following example we have a page with a _Link_ containing an empty implementation of _onClick_:

[source,java]
----
public class HomePage extends WebPage {
	public HomePage(){
		add(new Link("id"){
			@Override
			public void onClick() {
				//link code goes here
		    }			
		});
	}
}		
----

By default after _onClick_ has been executed, Wicket will send back to the current page to the client web browser. If we want to navigate to another page we must use method _setResponsePage_ of class _Component_:

[source,java]
----
public class HomePage extends WebPage {
	public HomePage(){
		add(new Link("id"){
			@Override
			public void onClick() {			   
                         //we redirect browser to another page.
                         setResponsePage(AnotherPage.class);
			}			
		});
	}
}
----

In the example above we used a version of _setResponsePage_ which takes as input the class of the target page. In this way a new instance of _AnotherPage_ will be created each time we click on the link. The other version of _setResponsePage_ takes in input a page instance instead of a page class:

[source,java]
----
@Override
public void onClick() {			   
	//we redirect browser to another page.
	AnotherPage anotherPage = new AnotherPage();
	setResponsePage(anotherPage);
}
----

The difference between using the first version of _setResponsePage_ rather than the second one will be illustrated in 
<<_page_versioning_and_caching,chapter 8>>, when we will introduce the topic of stateful and stateless pages. For now, we can consider them as equivalent. 

Wicket comes with a rich set of link components suited for every need (links to static URL, Ajax-enhanced links, links to a file to download, links to external pages and so on). We will see them in 
<<_wicket_links_and_url_generation,chapter 10>>.

NOTE: We can specify the content of a link (i.e. the text of the picture inside it) with its method _setBody_. This method takes in input a generic Wicket model, which will be the topic of 
<<_wicket_models_and_forms,chapter 11>>.

