Wading through the JavaEE ocean!!

A common requirement on MAF is to simulate a page button push using Javascript. To achieve this, what you need is a Javascript function that registers two events on the button – “touchstart” and “touchend”.

An use-case for this function may be to simulate clicking a search button when the user presses enter on the search key field. The typical way to do this would be to register a function against the keypress event on the window. The registered function in turn will invoke the pressAMXButton with the correct button id. For e.g.

Theres is a gotcha with this though. If you have multiple pages within the same MAF feature – say within a single taskflow – and the user navigates between these pages, then it may be required that you unregister any previous keypress bindings before adding the new one. If you don’t then, you may encounter the issue where the keypress function that was registered on the very first page continues to be active on other pages also. The effect of this is that the Javascript may attempt to press a button that doesn’t exist on the new page.
Use this bit of Javascript prior to registering the new keypress function. This snippet unbinds all keypress functions registered on the window.