X

The blog for hints & tips about Oracle Application Development Framework and Mobile Application Framework

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

Frank Nimphius
Master Principal Product Manager

In ADF Faces, to invoke a server side method in a managed
bean, you use the af:serverListener
tag. The af: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"
                   type="dblClick"/>
<af:serverListener type="TableDoubleClickEvent"                          
                   method="#{myBean.handleTableDoubleClick}"/>

</af:table>

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);        
  evt.cancel();
}

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.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.