There seems to be a problem resolving control id references when using the import template view.
In attachment you may find a sample able to reproduce the issue.
On my sample I have created a portlet with two views: Default and innerView.
On the default view you will find two tabs: One and Two.
For each of the tabs there’s an hideable panel with an import template view control within.
On the inner view you will find 2 controls: htmlOutputText (a basic text output) and htmlButton
I’ve placed a line of javascript (
alert("#{caf:cid('htmlOutputText')}");
) on the button so that it prints the control id reference for htmlOutputText.
The general rule for control id reference resolution is that it resolves for the “closest” control with the specified id. So, when inside tab Two, I was expecting it to resolve to jsfwmp19782:defaultForm:importTemplateTwo:innerForm:htmlOutputText (notice the importTemplateTwo part) but it resolves to jsfwmp19782:defaultForm:importTemplateOne:innerForm:htmlOutputText
However, in your use case it appears that they are just trying to resolve the id using an expression that is resolved during rendering. In this case, the framework doesn’t know what the ‘base’ component is to know where to begin the search from, so it always resolves the component from the root which would always find the first one (as expected).
My suggestion would be to use a more specific id for the lookup.
For example:
#{caf:cid(‘templateOneViewId:htmlOutputText’)}
#{caf:cid(‘templateTwoViewId:htmlOutputText’)}