Sonntag, Dezember 19, 2004
ADF: How to edit the current selected row
There are may possibilities to edit the current selecte row in usage of ADF-Bindings, ADF- BC4J and uiXML .
- First you can do the task with a table and input fields into the same page . This approach is very simple and also used within Jdev generated sample code. The underling bindingModel associate to the identical page name and so the bounded edit fileds associate always the same model.
- Next to edit the current row into an other page without hidding only the table or edit elements, you must change the associated BindingModel in the new page to the calling page. This is done in five steps: create a new ADF Struts DataAction, change the requested modelName in the getBindingContainerName() methode of your overwritten oracle.cabo.adf.rt.InitModelListener. Additional you should copy all bindingControls from the original UIModel to the underling Model. Into the uiXML page you should call the associated struts action after setting the current row:
<singleSelection model="${bindings.EmployeesViewIterator}" text="Select and "> <primaryClientAction> <fireAction source="EmployeesView0" event="select"> </fireAction>
</primaryClientAction>
....
<event name="select">
<compound>
<set target="${bindings.EmployeesViewIterator}" property="currentRowIndexInRange" value="${ui:tableSelectedIndex(uix, 'EmployeesView0')}"/>
<struts:action path="/selectEmp.do">
</struts:action>
</compound>
</event>
The rest is automatically done by ADF. - A other way is to write our own DataAction for the current user selection. Remove the single selection element from uiXML table and add a column with the following selection link:
<column>
<columnFormat columnDataFormat="numberFormat"/>
<columnHeader>
<sortableHeader model="${ctrl:createSortableHeaderModel(bindings.EmployeesView,'EmployeeId')}"/>
</columnHeader>
<contents>
<link text="${uix.current.EmployeeId.attributeValue}">
<boundAttribute name="destination">
<concat> <contextProperty select="ui:contextURI"/>
<fixed text="/selectEmp.do?id="/>
<dataObject source="${uix.current.EmployeeId.attributeValue}"/>
<fixed text="&event=select"/>
</concat>
</boundAttribute>
</link>
</contents>
</column>
Afterward the associated adf struts action should set the current row and navigate to the edit page with the struts action forward tag:
public void onSelect(DataActionContext ctx){
String id = (String)evalEL("${param.id}",ctx);
JUIteratorBinding iter = (JUIteratorBinding)evalEL("${bindings.EmployeesViewIterator}", ctx);
Key key = new Key(new Object[] {id});
Row[] rows = iter.getViewObject().findByKey(key,1);
iter.setCurrentRowWithKey(key.toStringFormat(true));
}