Oracle Fusion Middleware Tag Reference for Oracle ADF Faces
12c (12.2.1.2)

E76720-01

<af:serverListener>

serverListener server listener


The serverListener tag is a declarative way to register a server-side listener that should be executed when a custom client event is fired. This tag will be ignored for any server-rendered components, as it is only supported for the rich client. The target method must return void and take one argument, a ClientEvent object.

To fire a custom event from the client, use the AdfCustomEvent.queue() Javascript method:


/**
 * Convenience function for queueing an Custom event from a component.
 * @param {AdfUIComponent} Component to queue the custom event on
 * @param {String} the type of the event
 * @param {Object} a set of parameters to include on the event.  Reserved
 *    parameter names include "type" and "immediate".
 * @param (boolean) whether the custom event is "immediate" - which will
 *  cause it to be delivered during Apply Request Values on the server,
 *  or not immediate, in which case it will be delivered during
 *  Invoke Application. 
 * @final
 */
AdfCustomEvent.queue = function(component, type, params, immediate) { ... }
</section> <section name="Code_Example_s_">

This example will invoke the doCustomEvent() method on the server when a custom event of type "myCustomEvent" is sent to this component.


  <script>
  var inputComp = someOtherComp.findComponent("myInput");
  AdfCustomEvent.queue(inputComp,
                       "myCustomEvent",
                       // Send one parameter
                       {skyIsFalling:false},
                       // Make it "immediate" on the server
                       true);
  </script>
            
  <af:inputText clientComponent="true" id="myInput" value="Can send custom events">
     <af:serverListener type="myCustomEvent" method="#{bean.doCustomEvent}"/>
  </af:inputText>

   public void doCustomEvent(ClientEvent event)
   {
     if (Boolean.TRUE.equals(event.getParameters().get("skyIsFalling")))
     {
       ... ;
     }
   }

Attributes

Name Type Supports EL? Description
type String no the type of custom client-side component event to listen for
method String required an EL expression pointing to the server-side Java method to invoke when triggered by an event of type. The Java method must return void and take one argument, a ClientEvent object. type