xforms:setfocusAdded by IBM on August 8, 2013 | Version 1 (Original)
|Sets the focus to a particular presentation element in the form.
Also supports the xforms:control element. If the xforms:control element is present, the control attribute of xforms:setfocus is ignored.
<xforms:setfocus event control="id"/>
Table 1. setfocus parameters
|event||string||The XForms event that triggers the action.|
|id||string||The id of the XForms option inside the item that you want to have receive the focus. |
|XPath||XPath||An XPath expression that returns the id of the XForms option inside the item that you want to have receive the focus.|
Example The following examples shows a button that is used to add new rows to a table:
When the button is clicked by the user, the focus moves to the button itself. However, once the new row appears, it's preferable to send the focus back to the table.
To accomplish this, the xforms:setfocus is included as the last action for the button, and moves the focus back to the xforms:repeat that controls the table. The focus is then automatically placed on the row that was just added.
<xforms:insert nodeset="order/row" at="index('orderTable')"
- You can use xforms:setfocus to refer to specific items in a repeat template. In this case, the row index of the repeat determines which item gets the focus.
For example, consider a case in which each row of repeat X contains a field and a popup, and the repeat begins with an index of 2. You set the focus to the popup item. To locate this item, we first go to row 2 of the repeat, then find the popup within that row.
- Setting the focus to an element on a different page of the form will change the page that is displayed.