【问题标题】:Dynamic tabIndex-attribute in JSF/PrimefacesJSF/Primefaces 中的动态 tabIndex 属性
【发布时间】:2013-05-15 14:07:57
【问题描述】:

我遇到了 JSF/Primefaces 的问题。 我在我的 JSF 应用程序中的每个组件上使用 tabIndex 属性,以允许用户逐步浏览屏幕。 我编写了一些 JSF 复合组件来重用部分屏幕。现在我有一个问题,这些组件中的 tabIndex 是“硬编码的”,所以如果我重用这些组件,tabIndex 会与其他组件冲突,并且选项卡的顺序不会正确。

例子:

  ComponentA: tabIndexes: 1,2,3
  ComponentB: tabIndexes 1,2,3
  ComponentC: tabIndexes: 4,5,6

  ScreenA: Components: A,C --> no problem, because every tabIndex is unique.
  ScreenB: Components: B,C --> no problem, because every tabIndex is unique.
  ScreenC: Components: A,B,C --> problem, because of conflicting tabIndex.
  ScreenD: Components: A,B --> problem, because of conflicting tabIndex.

(任何组合都是可能的)

我认为我需要以动态方式创建 tabIndex-value,但我不知道如何做到这一点。 有人有想法吗?我会很高兴看到这方面的每一个提示。

【问题讨论】:

  • 您能否更具体地了解您的设置。提供代码来支持您的要求。我不太符合你的要求。

标签: jsf-2 primefaces tabindex


【解决方案1】:

不确定我是否关注,但可能是这样的?

tabindex="#{tabIndexBean.getIndex}"

方法:

int index=0;
public int getIndex() {
    index++;
    return index;
}

【讨论】:

  • 好人!您的解决方案使我找到了正确的方法。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-05-17
  • 2012-05-17
  • 1970-01-01
  • 2015-02-28
  • 1970-01-01
  • 1970-01-01
  • 2013-06-17
相关资源
最近更新 更多