Action Events are a very powerful mechanism to develop web interfaces. It allows you to attach buttons in your web form to method calls in a class. The Action Events How To provides a good description of how to use this tool. This part of the tutorial presents an approach to extend the use of action events, attaching every kind of javascript event (e.g.: onBlur, onClick, onMouseOver) to method calls in the ActionEvent class.

Wrapping the document.yourform.submit() function in javascript is a common practice that allows you to validate the fields of the form before submitting. In order to attach js events to method calls you need to do something similar:

  • put a hidden element in the form:
    <input type="hidden" name="actionevent" value=''''''> 
  • wrap the form.submit() in a js function that changes the actionevent name
    doSubmit(actionevent_name){ 
       document.formname.actionevent.name=actionevent_name;  
       document.formname.submit(); 
    } 
  • and call it at any time in your html code with the action event name.
    onBlur="doSubmit('eventSubmit_doYourMethodName)" 

This will result in a call to doYourMethodName method in the ActionEvent class.

  • No labels