Quantcast
Channel: Oracle Bloggers
Viewing all articles
Browse latest Browse all 19780

JavaScript function to intercept or listen for tab remove event

$
0
0

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

tabRemovalValid 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

 

itemListenerjavax.el.MethodExpressionOnly ELa 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"/>
     </af:showDetailItem></af:panelTabbed

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


Viewing all articles
Browse latest Browse all 19780

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>