All functions that are not directly related to the user interface should be handled in the controller to ensure clear separation between UI and data. In this case you add a method to handle the event, which is attached to a button.
#!javadoIt : function(oEvent) { alert(oEvent.getSource().getId() + " does it!"); }