Active index is not updated automatically. ReaD in a few posts by placing the tabView in the form in which it works. Or by including <p:ajax event="tabChange"/>
in tabview, it works. But nothing works
XHTML
Example 1: automatic updates
<p:tabView id="categoryTabView" var="promoArticle" value="#{promotionDetailBean.artDTOs}" activeIndex="#{promotionDetailBean.activeTabIndex}"> <p:tab id="categoriesTab" title="#{promoArticle.categoryName}"> <p:dataTable id="promotionDetail_dataTable" var="articlePromo" value="#{promoArticle.artVO}" selection="#{promotionDetailBean.selectedArt}" rowIndexVar="rowIndex"> <p:column id="select" selectionMode="multiple" /> <p:column id="barCode"> <h:inputText id="barCodeInputTxt" value="#{articlePromo.barCode}" styleClass="inputTextStyle" onchange="onSuggestedValueChange('categoryTabView',#{promotionDetailBean.activeTabIndex}, 'promotionDetail_dataTable',#{rowIndex},'originalCostInputTxt')" /> </p:column> </p:dataTable> </p:tab> </p:tabView>
Example 2: Updating the tabChange Event
<h:form id="form"> <p:growl id="growlm" showDetail="true" /> <p:tabView id="categoryTabView" var="promoArticle" value="#{promotionDetailBean.artDTOs}" > <p:ajax event="tabChange" listener="#{promotionDetailBean.tabChanged}" update=":growlm" /> <p:tab id="categoriesTab" title="#{promoArticle.categoryName}"> <p:dataTable id="promotionDetail_dataTable" var="articlePromo" value="#{promoArticle.artVO}" selection="#{promotionDetailBean.selectedArt}" rowIndexVar="rowIndex"> <p:column id="select" selectionMode="multiple" /> <p:column id="barCode"> <h:inputText id="barCodeInputTxt" value="#{articlePromo.barCode}" styleClass="inputTextStyle" onchange="onSuggestedValueChange('categoryTabView',#{promotionDetailBean.activeTabIndex}, 'promotionDetail_dataTable',#{rowIndex},'originalCostInputTxt')" /> </p:column> </p:dataTable> </p:tab> </p:tabView>
I need to identify a cell on the onChange event. But activeIndex is always 0, an initialized value. The event does not receive the call.
bean
private Integer activeTabIndex = 0; public Integer getActiveTabIndex() { return activeTabIndex; } public void setActiveTabIndex(Integer activeTabIndex) { this.activeTabIndex = activeTabIndex; }
bean
public void tabChanged(TabChangeEvent event){ TabView tv = (TabView) event.getComponent(); this.activeTabIndex = tv.getActiveIndex(); }
But the event does not become a trigger. Also not updated automatically.
What are the possible problems?
Thanks Shikha
source share