title: Create listener for CustomComponent in Vaadin
body: <p>I'm trying to create a <code>CustomComponent</code> in vaadin 7. The component has a <code>VerticalLayout</code> set in its <code>setCompositionRoot()</code> method and some Labels and other layouts are set within that <code>VerticalLayout</code>. Implementing my custom component in the main view class I would like to be able to handle clicks on my custom component, meaning the <code>VerticalLayout</code> as the composition root element:</p>
  
  <pre class="lang-java prettyprint-override"><code>MyCustomComponent component = new MyCustomComponent();
  component.addOnClickListener(listener);
  </code></pre>
  
  <p>But there is no method like <code>addOnClickListener</code> available. How can I implement that functionality? I know that I can handle a click on a layout with the <code>LayoutClickListener</code> within the custom component, but is there also a way that I can set the listener, where the component is declared, e.g. in the main view class (similar to the code snippet above)?</p>