星期日, 十一月 26, 2006

Oracle ADF Table使用(CoreTable)

创建java Object VO:
public class ParamVO {
private int name;
private int type;

public void setName(String name) {
this.name=name;
}

public String getName() {
return name;
}

public void setType(int type) {
this.type = type;
}

public int getType() {
return type;
}
}

jspx页面的代码:

<af:table emptyText="No items were found" value="#{paramsList}" var="row" id="paramTable">
<af:column sortable="false" headerText="Name" id="column1">
<af:outputText value="#{row.name}" id="outputText1"/>
</af:column>
<af:column sortable="false" headerText="ParamType" id="paramTypeColumn">
<af:selectOneChoice value="#{row.type}" id="paramType"
label="Label 2" autoSubmit="true" immediate="true"
valueChangeListener="#{backing_dp_functionChooseParams2.changeParamType}">
<af:selectItem label="In" id="selectItem1" value="1"/>
<af:selectItem label="Out" id="selectItem2" value="2"/>
<af:selectItem label="InOut" id="selectItem3" value="3"/>
</af:selectOneChoice>
</af:column>
</af:table>

得到table中的Object, ADF中table的每一行是一个VO对象:

int numRows = this.getParamTable().getRowCount();
for(int i=0; i<numRows; i++) {
ParamVO paramVO = (ParamVO)this.paramTable.getRowData(i);
}

得到table中选中的记录:

CoreTable table = this.getParamTable();

Set rowSet = table.getSelectionState().getKeySet();

Iterator rowSetIter = rowSet.iterator();
BindingContainer bindings = getBindings();
DCIteratorBinding pr_dcib = (DCIteratorBinding) bindings.get ("findAllParamsIter");
while (rowSetIter.hasNext()){
Key key = (Key) rowSetIter.next();
pr_dcib.setCurrentRowWithKey(key.toStringFormat(true));
RowImpl prRow = (RowImpl) pr_dcib.getCurrentRow();
ParamVO prToCopy = (ParamVO) prRow.getDataProvider();
}

没有评论: