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

JavaScript function to intercept or listen for tab remove event

Frank Nimphius
Master Principal Product Manager

The af:panelTabbed component allows you to remove tabs from display using the tabRemoval property

tabRemoval Valid Values: none, all, allExceptLast

determines if tab removal is enabled.

This attribute supports these tabRemoval types:

  • none - tab removal is not enabled.
  • all - tab removal is enabled on all tabs, regardless if they are disclosed. The last tab in the panelTabbed can be removed.
  • allExceptLast - tab removal is enabled on all tabs, regardless if
    they are disclosed. The last tab in the panelTabbed cannot be removed.

 src: http://docs.oracle.com/cd/E35521_01/apirefs.111230/e17491/tagdoc/af_panelTabbed.html

Because tab removal is not automatic in ADF Faces, developers configure an item listener on the af:showDetailItem component that make the tabs within a panel tab

itemListener javax.el.MethodExpression Only EL a method reference to an item listener

src: http://docs.oracle.com/cd/E35521_01/apirefs.111230/e17491/tagdoc/af_showDetailItem.html

"Choosing to remove a tab will cause an ItemEvent of type 'remove' to
be launched. This event can be listened for on a showDetailItem using
the itemListener attribute. It is up to the developer to handle this
event and code the actual removal of the tab. This is because of the
dynamic nature of the panelTabbed component, which may have dynamic
children. This also allows a finer level of control by the developer,
who can then choose a custom implementation that may (for example)
include warning dialogs, and control of which tab gains focus after a
tab is removed."

src: http://docs.oracle.com/cd/E35521_01/apirefs.111230/e17491/tagdoc/af_panelTabbed.html

This apparently works with logic written in Java saved on the server. A question on OTN was how to handle or intercept this remove event on the client side using JavaScript. This information - unfortunately - is a bit hidden in our documentation and you have to look into the JavaScript documentation for this.

src: http://docs.oracle.com/cd/E35521_01/apirefs.111230/e17489/oracle/adf/view/js/event/AdfItemEvent.html

If there is an AdfItemEvent that fires on the ADF Faces client side, then there also must be a configuration available on the af:clientListener to listen for such an event. And there is (just not obvious)

 <af:panelTabbed id="pt1" tabRemoval="all">  
    <af:showDetailItem text="TAB 1" id="sdi1" stretchChildren="first" clientComponent="false">
         <af:clientListener method="alertTabClose" type="item"/>

The JavaScript function to this looks similar to

function alertTabClose (closureEvent){
var tab = closureEvent.getSource();

This allows you to handle (and suppress) the tab remove event on the client using JavaScript in ADF Faces

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.