OverviewThe tab view component allows you to group UI element in different tabs, as done in the XForms controls example:![]() The basic syntax goes as follows: <fr:tabview> <fr:tab> <fr:label>Label of first tab</fr:label> Content of first tab. </fr:tab> <fr:tab> <fr:label>Label of second tab</fr:label> Content of second tab. </fr:tab></fr:tabview>Hiding and disabling tabsYou can bind the fr:tab to a node in your instance (single-node binding). When doing this:
When the fr:tabview becomes enabled, the first relevant tab becomes the current tab. If you want another tab to be current tab, dispatch the fr-toggle event to that tab (more on this below).It is your responsibility as an XForms author not to hide or to disable the current tab. The tabview component doesn't stop you from doing this, which might lead to inconsistent UI state. EventsKnowing when users changed tabThe eventsfr-select and fr-deselect are notification events that tell you when users switch between tabs. You do not need to listen to those events for the tab view to work effectively. Even if you don't put listeners on those events, the tab view will switch between tab as users click on the labels for those tabs.The fr-select event is dispatched to the fr:tab the user selected, while fr-deselect is dispatched to the fr:tab the user came from. Those events are dispatched after the UI is updated, and so they can't be used to cancel the user going to another tab before the switch to that tab happens.You can use those events to lazily load data into a tab, i.e. to only load the data needed to display a tab when users switch to those tabs, as done in the following snippet: <fr:tab> <fr:label>Target tab</fr:label> <xforms:action ev:event="fr-select"> <xforms:send submission="load-data-submission"/> <xforms:toggle case="data-loaded"/> </xforms:action> <xforms:switch> <xforms:case> <xhtml:img src="/ops/images/yui/loading.gif" style="vertical-align: middle"/> <xhtml:span>Loading data...</xhtml:span> </xforms:case> <xforms:case id="data-loaded"> <xhtml:img src="/apps/fr/style/images/silk/tick.png" style="vertical-align: middle"/> <xhtml:span>Data loaded.</xhtml:span> ... Display data here .... </xforms:case> </xforms:switch></fr:tab>Switching to another tabYou can programmatically switch to a tab by dispatching the event fr-toggle to the fr:tab you want to switch to.
Also, if you set the focus to a control with <xforms:setfocus>, and that control is not in a visible tab, then the fr:tabview will automatically switch to tab so the control becomes visible.Limitations
|
