Expression binding referencing tab index only working after tab is changed

I have a view which contains (among other things), two embedded views. I will refer to the view as the "host" view for lack of a better term. The first embedded view has in it a tab container, and an output parameter called currentTab. The output parameter is bound to the currentTabIndex of the tab container, so that whenever I embed the view, the currently selected tab index of the embedded view is accessible to the view into which it is embedded.

My second embedded view should only appear when (a) an input parameter to the host view showSecondView is true, and when the first embedded view is currently displaying Tab 0. To this end, I have an expression binding on the display property of the second embedded view:
{view.params.showSecondView} && {/root/EmbeddedViews/EmbeddedView1.props.params.currentTab} = 0
Thus, when tab zero is selected in the first embedded view, I should get a zero at the currentTab output parameter, and my expression binding should evaluate to true (provided the showSecondView parameter is also true).

At runtime, the host view is displayed in the form of an onDemand dock. I have a little icon with an Open Dock event associated with it, and when I click it, the view appears with the first embedded view showing tab zero. However, the second embedded view does not show up.

When I click to a different tab, and then back to tab zero, it shows up.

It's as if the output parameter is not populated until the tab is changed, so I added two things to my host view to troubleshoot:

  1. A numeric indicator bound to {/root/EmbeddedViews/EmbeddedView1.props.params.currentTab}
  2. A checkbox with the checked parameter bound to the expression {/root/EmbeddedViews/EmbeddedView1.props.params.currentTab} = 0

The first one (numeric indicator) indicates zero straight away, as you'd expect.
The second one (checkbox) should show up checked straight away, since the numeric indicator has confirmed that the value of {/root/EmbeddedViews/EmbeddedView1.props.params.currentTab} is indeed zero, and it's expression is simply {/root/EmbeddedViews/EmbeddedView1.props.params.currentTab} = 0 - but it doesn't. It starts unchecked, and when I switch to another tab and back again, it then shows up checked.

How can I troubleshoot this?

What version is this ?
I can't reproduce the issue in 8.1.21.

Do you NEED an embedded view with a tab container ? Is there something else in there, or could you try with a simple tab container put directly in host ?

I haven't time to replicate the problem but I would be inclined to create a session variable to keep track of the selected tab. Bidirectionally bind the currentTabIndex to the session variable. You can then use the session variable in your second view display expression. This approach avoids the up and down traversal through the views and may solve the problem.

I slept on it and realised early this morning that it stopped working shortly after I added functionality to set the initial tab when the dock was first opened (i.e. I can click on an "alarms" icon to open it at the alarms tab, or a "settings" icon to open it at the settings tab).

I had a script that just wrote an input parameter startTab to the tab container's currentTabIndex. For some reason, the values were being passed in as strings. The tab container happily accepted the strings 0, 1 or 2 and set the appropriate tab, and the output parameter happily reported that the currentTabIndex was '0', and the expression binding correctly informed me that string '0' does not equal the number zero.

Once I changed the tab manually, it wrote a numerical 0 back to the currentTabIndex and everything worked as it should.

So anyway, I just updated my script to force the received parameter to be an integer before sending it to currentTabIndex and away we go.

God damn data type errors...

Javascript and JSON. Not my favorites.