Shi*_*wan 9 primefaces tabview
Active Index未自动更新.通过将tabView放在可以使用的表单上来回顾一些帖子.或者通过<p:ajax event="tabChange"/>在tabview中包含它是有效的.但似乎没有任何效果
XHTML
示例1:自动更新
<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>
Run Code Online (Sandbox Code Playgroud)
示例2:更新tabChange事件
<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>
Run Code Online (Sandbox Code Playgroud)
我需要在"onChange"事件中识别单元格.但activeIndex始终为0,即初始值.该活动未接到电话.
豆
private Integer activeTabIndex = 0;
public Integer getActiveTabIndex() {
return activeTabIndex;
}
public void setActiveTabIndex(Integer activeTabIndex) {
this.activeTabIndex = activeTabIndex;
}
Run Code Online (Sandbox Code Playgroud)
豆
public void tabChanged(TabChangeEvent event){
TabView tv = (TabView) event.getComponent();
this.activeTabIndex = tv.getActiveIndex();
}
Run Code Online (Sandbox Code Playgroud)
但事件并没有得到发展.也不会自动更新.
可能的问题是什么?
谢谢,Shikha
小智 13
当选项卡不包含在表单中但每个选项卡包含自己的选项卡时,这适用于我:
将标签更改事件的监听器添加到tabView组件:
<p:ajax event="tabChange" listener="#{userBean.onTabChange}" />从基础TabView组件获取活动索引似乎不起作用.但是,在这种情况下,新选择的选项卡会正确更新,因此我们可以通过搜索TabView的子组件来获取索引:
public void onTabChange(TabChangeEvent event)
{
TabView tabView = (TabView) event.getComponent();
activeTab = tabView.getChildren().indexOf(event.getTab());
}
我希望这也适合你
以下对我有用:
XHTML:
<p:tabView id="categoryTabView" var="promoArticle"
value="#{promotionDetailManagedBean.articuloPromocionDTOs}" dynamic="true">
<p:ajax event="tabChange" listener="#{promotionDetailManagedBean.onTabChange}" />
<p:tab> ... </p:tab>
</p:tabView>
Run Code Online (Sandbox Code Playgroud)
豆:
public final void onTabChange(final TabChangeEvent event) {
TabView tv = (TabView) event.getComponent();
this.activeTabIndex = tv.getActiveIndex();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29844 次 |
| 最近记录: |