1
votes

I'm facing an issue with JSF / Primefaces. I'm using the tabIndex-attribute on every component in my JSF-application to allow the user to step through the screens. I wrote some JSF composite components to reuse parts of the screen. Now I have the issue, that the tabIndex in these components is "hard-coded", so if I reuse the components, the tabIndex conflicts with other components and the tabbing will not be in the correct order.

Example:

  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.

(Every combination is possible)

I think I need to create the tabIndex-value in a dynamic way, but I have no clue on how to do that. Does someone have an idea? I would be happy for every hint on that.

1
Can you be more specific on your setup. Provide the code to back up your requirement. I don't quite follow what you want. - skuntsel

1 Answers

2
votes

Not sure I follow but maybe something like this?

tabindex="#{tabIndexBean.getIndex}"

Method:

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