Invoking JavaScript directly from the user interface

Rather than intercepting every event generated by the UI on the client, components can be instructed to invoke client-side JavaScript™ directly. In this case, the component will not sent a ClickEvent event to the server.

The code for assigning JavaScript methods to clickable components resides on the server. The example below finds the options menu item on the Data Menu and forces the menu item to invoke a JavaScript method (alternatively, the menu item can be set to load a browser URL).
<blox:present id="samplePresent" width="700" height="500">
<%
  // Find the component
  BloxModel model = samplePresent .getBloxModel();
  Component component = model.searchForComponent(
    ModelConstants.DATA_OPTIONS );

// Create a client link using javascript:protocol method
   ClientLink link = new ClientLink(“javascript:
      myJavaScriptFunction( );” );

  // Set the link on the component
  component.setClientLink( link );
%>
</blox:present>

When the Data Options menu item is clicked, the client will invoke the JavaScript myJavaScriptFunction() function rather than send the event to the server. It is assumed that the JavaScript function has been already defined on the page.