按下 Tab 键时将光标移动到下一个 inputText JSF
Move cursor to the next inputText when Tab key is pressed JSF
我有多个 inputText,用户必须在其中输入他的姓名、年龄、体重、身高。问题是当我按下 Tab 键时,它应该将光标从名字移动到年龄,但它直接移动到体重。
任何想法可能是什么问题。
在每个 UI 组件(文本字段、link、按钮)中添加 tabindex
属性,其中包含表示序列中步骤的数字。见 doc:
tabindex - javax.el.ValueExpression (must evaluate to java.lang.String) - Position of this element in the tabbing order for the current document. This value must be an integer between 0 and 32767.
示例:
<h:outputLabel for="user" value="#{msg.userId}"/>
<h:inputText id="user" value="#{login.userName}" tabindex="1" />
<h:commandLink value="#{msg.forgotUser}?" action="forgotUser" tabindex="4" />
<h:outputLabel for="password" value="#{msg.password}" />
<h:inputSecret id="password" value="#{login.password}" tabindex="2" />
<h:commandLink value="#{msg.forgotPassword}?" action="#{forgotPassword}" tabindex="5" />
<h:commandButton value="#{msg.login}" type="submit"
action="#{login.login}" tabindex="3" />
我有多个 inputText,用户必须在其中输入他的姓名、年龄、体重、身高。问题是当我按下 Tab 键时,它应该将光标从名字移动到年龄,但它直接移动到体重。 任何想法可能是什么问题。
在每个 UI 组件(文本字段、link、按钮)中添加 tabindex
属性,其中包含表示序列中步骤的数字。见 doc:
tabindex - javax.el.ValueExpression (must evaluate to java.lang.String) - Position of this element in the tabbing order for the current document. This value must be an integer between 0 and 32767.
示例:
<h:outputLabel for="user" value="#{msg.userId}"/>
<h:inputText id="user" value="#{login.userName}" tabindex="1" />
<h:commandLink value="#{msg.forgotUser}?" action="forgotUser" tabindex="4" />
<h:outputLabel for="password" value="#{msg.password}" />
<h:inputSecret id="password" value="#{login.password}" tabindex="2" />
<h:commandLink value="#{msg.forgotPassword}?" action="#{forgotPassword}" tabindex="5" />
<h:commandButton value="#{msg.login}" type="submit"
action="#{login.login}" tabindex="3" />