Search This Blog


Wednesday, November 16, 2011

ADF: How-to access UI component that queued a custom client event

In ADF Faces, to invoke a server side method in a managed bean, you use the af:serverListener tag. Theaf:serverListener tag is added as a child to the component that owns the event and called from JavaScript in a call to AdfCustomEvent.queue( … )
In this example, the af:serverListener is added to a table to notify a manage bean method about a double-click action.
<af:table ...>
 <af:column> ... </af:column>
 <af:clientListener method="handleTableDoubleClick"
<af:serverListener type="TableDoubleClickEvent"                          
The JavaScript function that is called by the af:clientListener is shown next.
function handleTableDoubleClick(evt){   
  var table = evt.getSource();
  AdfCustomEvent.queue(table, "TableDoubleClickEvent",{}, true);         
The first argument in the call to AdfCustomEvent.queue represents the event owner, the table component. This information is passed to the managed bean method, which has the following signature.
public void handleTableDoubleClick(ClientEvent ce){
  RichTable richTable = (RichTable)ce.getComponent(); 
  //... work with rich table component
As you can see, there is no need to look up the event owning component by searching the JSF UIViewRoot with or without help of JSFUtils.