JSF/Primefaces中的动态tabindex属性



我面临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,但我不知道如何做到这一点。有人有什么主意吗?

不确定我遵循,但也许是这样的东西?

tabindex="#{tabIndexBean.getIndex}"

方法:

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

最新更新