You are here: Home ยป Blog

List binding for selectOneChoice

Posted on Wednesday, March 19 2014 at 10:58 | Category: Oracle ADF & JDeveloper | 0 Comment(s)

In order to add a drop down box with a list of selectable values inside an af:tree or af:treeTable cell, an af:selectOneChoice component can be used:

<af:selectOneChoice id="soc1" 
    <f:selectItems id="si1" value="#{bindings.SelectionList.items}"/>

The two important attributes are the value attributes:

  • On the inner f:selectItems element, it defines the list binding which delivers the list of values to show in the drop down box.
  • On the af:selectOneChoice element, it defines the foreign key attribute from the current row (determined by node or row as set in the var attribute of the af:table or af:treeTable) which references the corresponding primary key from the selection list. The mapping between the foreign key and the primary key attributes is defined in the list binding in the respective pageDef file.

Now, there is one important detail to know about this list binding: When it is created automatically by JDeveloper when dragging an attribute from the Data Control panel onto the jsf page, the IDE automatically adds the attribute SelectItemValueMode="ListObject" to the list binding definition. This is absolutely crucial for the list binding to properly map foreign keys to primary keys. Without this attribute, the mapping is not done through the key mapping, but through the index of the entry in the selection list - thus, foreign key 2 would map to the second entry in the selection list (SelectItemValueMode="ListIndex" which is also the default if the attribute is missing).

Now, the point is: This attribute is not added to the binding if we create the list binding manually through the bindings editor. The dialog which is shown when manually creating the list binding also does not provide the possibility to select one or the other value for the attribute.

So, if we have created the list binding manually (which is sometimes convenient), it is automatically in mode SelectItemValueMode="ListIndex". In order to change it to ListObject, we need to manually change it in the property editor (or in the XML source code)!

The same, by the way, happens for the DTSupportsMRU attribute of the list binding - when the binding is added by the IDE through drag&drop from the data control panel, this attribute is added automatically so that the list binding supports most recently used entries. When created manually through the binding editor, the attribute is not added - you need to add it manually in the XML code after the binding has been created.

Displaying results 21 to 21 out of 21
<< First < Previous 1-4 5-8 9-12 13-16 17-20 21-21 Next > Last >>