How to add tab index of selectOneChoice of Oracle's ADF?
How to add tab index of selectOneChoice of Oracle's A开发者_StackOverflowDF ?
Unfortunately, you cannot control it at standard JSF level. At least, not with the standard components and renderers. The specified tabindex
will be applied on all generated elements (I don't to ADF, but I guess that it are the radio buttons).
You could consider to override the renderer associated with the af:selectOneChoice
so that it takes an addidional attribute tabindexes
or so accepting a commaseparated string of indexes and applies them on the generated radiobuttons subsequently.
You need to consult the ADF documentation of the component in question to find out which component family it belongs and which renderer it is using. Once found out, you basically need to create a class which extends
it and overrides the renderOption()
method (at least, it is called with exactly that name in the JSF standard com.sun.faces.renderkit.html_basic.RadioRenderer
class). You basically need to copy the method logic (not sure about ADF, but basic JSF implementations are open source) and add the following logic to it:
String tabindexes = (String) component.getAttributes().get("tabindexes");
if (tabindexes != null) {
String[] tabindexItems = tabindexes.split("\\s*,\\s*");
String indexKey = component.getClientId(context) + "_currentTabIndex";
Integer index = (Integer) component.getAttributes().get(indexKey);
if (index == null || index == tabindexItems.length) {
index = 0; // Note this thus restarts at 0 if there are more selectitems than tabindexes. Just to be on the safe side.
}
String tabindex = tabindexItems[index];
component.getAttributes().put(indexKey, ++index); // We need to save it for the next generated input element.
writer.writeAttribute("tabindex", tabindex, "tabindex");
}
If you declare the custom renderer in faces-config.xml
as follows
<render-kit>
<renderer>
<component-family>put here the component family of af:selectOneChoice</component-family>
<renderer-type>put here the renderer type of af:selectOneChoice</renderer-type>
<renderer-class>com.example.YourCustomRadioRenderer</renderer-class>
</renderer>
</render-kit>
then you can use the extra tabindexes
attribute as follows:
<af:selectOneChoice .... >
<f:attribute name="tabindexes" value="1,3,5,7,2,4,6,8" />
You can even put some EL in it so that you can obtain it as a (generated) string from the bean property.
<af:selectOneChoice .... >
<f:attribute name="tabindexes" value="#{bean.tabindexes}" />
Hope this gives new insights.
精彩评论