- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我尝试获取任何 Accordion 面板的事件索引时,它总是返回 -1 值。我使用的是 primefaces 7.0 版本。
当我尝试启用表单标签时,它无法逐步处理流程。
我也尝试过 stackoverflow 的其他解决方案,但对我来说没什么用。任何人都知道这一点。
1.example.xhtml
<!-- <h:form> -->
<ui:fragment
rendered="#{not empty excursionResultsBean.excursionAvailabilities and not empty excursionResultsBean.excursionAvailabilities[0].excursionCategoryBeans}">
<p:accordionPanel multiple="false"
activeIndex="#{panelDisplayBean.index}" role="tablist" id="indexId" cache="false" >
<f:ajax event="tabChange"
listener="#{excursionResultsBean.onTabChange}" update="@form"/>
<ui:insert name="creditCardPanel1">
<ui:include src="step1.xhtml" />
</ui:insert>
<ui:insert name="creditCardPanel2">
<ui:include src="step2.xhtml" />
</ui:insert>
<ui:insert name="creditCardPanel3">
<ui:include src="step3.xhtml" />
</ui:insert>
<ui:insert name="creditCardPanel4">
<ui:include src="step4.xhtml" />
</ui:insert>
</p:accordionPanel>
</ui:fragment>
<ui:fragment
rendered="#{empty excursionResultsBean.excursionAvailabilities or empty excursionResultsBean.excursionAvailabilities[0].excursionCategoryBeans}">
<div>
<p>Sorry! We're booked to capacity on your flight</p>
Please share your travel details with us at <b><a
href="mailto:guest.ss@ss.com">guest.ss@ss.com</a></b>,
so that we can work on this specially for you! Or call
</div>
</ui:fragment>
<!-- </h:form> -->
bean 中的方法
public void onTabChange(TabChangeEvent event) {
UITabPanel tabView = (UITabPanel) event.getComponent();
int activeTab = tabView.getChildren().indexOf(event.getTab());
System.out.println("Active index "+activeTab);
}
最佳答案
Tab
或任何 UIComponent
没有 equals(Object obj)
方法的实现。所以 tabView.getChildren().indexOf(event.getTab())
永远不会给你标签索引(因为它使用了 equals
方法)。
您可以做的是检查 clientId
,同时遍历子项以找到选项卡索引。不过,并非每个子项本身都是 Tab
,所以要对此进行补偿。
public void onTabChange(TabChangeEvent event) {
UIComponent component = event.getComponent();
String clientId = event.getTab().getClientId();
int index = -1;
for (int i = 0; i < component.getChildCount(); i++) {
UIComponent child = component.getChildren().get(i);
// Not each child is a tab per se
if (child instanceof Tab) {
index++;
if (clientId.equals(child.getClientId())) {
// Found it, break out of the for loop
break;
}
}
}
System.out.println("index " + index);
}
我已经用以下代码测试了上面的代码:
<p:accordionPanel>
<!-- comment -->
<p:tab title="1"></p:tab>
<!-- comment -->
<p:tab title="2"></p:tab>
<p:tab title="3"></p:tab>
<p:ajax event="tabChange" listener="#{testView.onTabChange}"/>
</p:accordionPanel>
关于jsf - 如何在支持 bean 中使用 primefaces 通过 accordionPanel 获取事件索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69008718/
我想用带有多行标题的选项卡制作 Accordion 组件。 是否可以在 accordion 组件中将 tab header 设为多行? 我使用的是最新的 Primefaces 4.0-rc1。 谢谢
我的页面中有一个 accordionPanel 和时间表。但是当我展开我的 accordionPanel 时,我的日程安排就会下降。为什么?我使用primefaces。 我添加了一个屏幕:http:/
XHTML 文件: ... ...
当您在 AccordionPnel 中展开或折叠选项卡时会出现动画,并且在繁忙的应用程序中它会变得非常缓慢,我想摆脱它。我该怎么做? 最佳答案 也许这对你有帮助,
我试图用 css 删除 Accordion 选项卡的顶行,但没有成功。以下是我的代码片段。我尝试了几种 css 样式,但它没有响应。请教如何删除 Accordion 中每个选项卡上方的默认栏。
我无法关闭所有 p:accordionPanel 选项卡 我尝试了问题 Hiding the first tab of accordion panel in JSF Primefaces 中推荐的两种
我正在尝试运行这个简单的页面: Últimas Notícias 其中 noticia.feed 是 Noticia 对象列表。 当我尝试运行此页面时,遇到以下错误:
当我尝试获取任何 Accordion 面板的事件索引时,它总是返回 -1 值。我使用的是 primefaces 7.0 版本。 当我尝试启用表单标签时,它无法逐步处理流程。 我也尝试过 stackov
我有一个 p:accordionPanel,它代表一个项目列表,在每个选项卡中都有一个表单。在提交任何重复表单时,可能需要额外的数据,即弹出 p:dialog 提示用户输入更多数据。该对话框定义在 A
我有一个显示一些选项卡的页面。每个选项卡都包含一个 Accordion 。 从技术上讲,我有一个 p:tabView 组件,其中包含四个 p:tab。我们将它们称为 p:tabView > p:tab
我是一名优秀的程序员,十分优秀!