プロジェクトでエラーが発生しています。私はOracle ADFで開発しています。概要は次のとおりです。
2 つのビュー、browseBusiness (デフォルト ビュー) と chooseBusiness を含むタスクフローがあります。次に、タスク フローの領域を含む jspx ページがあります。
BrowseBusiness には、追加と削除の 2 つのボタンがあります。[追加] を押すと、chooseBusiness が表示され、列の 1 つにチェックボックスが表示されます。その一部を確認し、[保存] をクリックすると、選択した行を反復処理してデータベースに保存する必要があります。
私の問題は、ビジネスの保存中に反復に失敗したことです。保存するコードは次のとおりです。
final RichTable table = this.getBisnisTabel();
final AppModuleImpl appModul =
(AppModuleImpl)ADFUtil.getApplicationModule("AppModuleDataControl");
FacesContext facesContext = FacesContext.getCurrentInstance();
VisitContext visitContext =
RequestContext.getCurrentInstance().createVisitContext(facesContext, null, EnumSet.of(VisitHint.SKIP_TRANSIENT,
VisitHint.SKIP_UNRENDERED),
null);
//ERROR IN HERE
UIXComponent.visitTree(visitContext, facesContext.getViewRoot(), new VisitCallback() {
public VisitResult visit(VisitContext context, UIComponent target) {
if (table != target) {
return VisitResult.ACCEPT;
} else if (table == target) {
//Here goes the Actual Logic
//for adding new Business
selectAllRowsInTable(table);
Iterator selection = table.getSelectedRowKeys().iterator();
while (selection.hasNext()) {
Object key = selection.next();
//store the original key
Object origKey = table.getRowKey();
try {
table.setRowKey(key);
Object o = table.getRowData();
JUCtrlHierNodeBinding rowData = (JUCtrlHierNodeBinding)o;
Row row = rowData.getRow();
if (row.getAttribute
("Selected") != null) {
if ((Boolean)row.getAttribute("Selected"))
{
appModul.saveMTypeOfPolicyGrpBizCode(row.getAttribute("BizCode").toString());
row.setAttribute("Selected", false);
}
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
//restore original key
table.setRowKey(origKey);
}
}
}
return VisitResult.COMPLETE;
}
});
これは、テーブル内のすべての行を選択するためのコードです:
public void selectAllRowsInTable(RichTable rt) {
RowKeySet rks = new RowKeySetImpl();
CollectionModel model = (CollectionModel)rt.getValue();
int rowcount = model.getRowCount();
for (int i = 0; i < rowcount; i++) {
model.setRowIndex(i);
Object key = model.getRowKey();
rks.add(key);
}
rt.setSelectedRowKeys(rks);
}
BrowseBusiness ビューで同様のコードを使用して deleteBusiness を実行すると、非常にスムーズに実行されるため、混乱しています。コードは次のとおりです。
final RichTable table = this.getBizPolicyTable();
final AppModuleImpl appModul =
(AppModuleImpl)ADFUtil.getApplicationModule("AppModuleDataControl");
FacesContext facesContext = FacesContext.getCurrentInstance();
VisitContext visitContext =
RequestContext.getCurrentInstance().createVisitContext(facesContext,
null,
EnumSet.of(VisitHint.SKIP_TRANSIENT,
VisitHint.SKIP_UNRENDERED),
null);
//Annonymous call
UIXComponent.visitTree(visitContext, facesContext.getViewRoot(),
new VisitCallback() {
public VisitResult visit(VisitContext context,
UIComponent target) {
if (table != target) {
return VisitResult.ACCEPT;
} else if (table == target) {
//Here goes the Actual Logic
//for deleting multiple Business of Policy
CollectionModel cm =
(CollectionModel)getBizPolicyTable().getValue();
RowKeySet rowKeySet =
(RowKeySet)getBizPolicyTable().getSelectedRowKeys();
Object[] rowKeySetArray = rowKeySet.toArray();
for (Object key : rowKeySetArray) {
cm.setRowKey(key);
//store the original key
JUCtrlHierNodeBinding rowData =
(JUCtrlHierNodeBinding)cm.getRowData();
try {
Row row = rowData.getRow();
appModul.deleteMTypeOfPolicyGrpBizCode(row);
} catch (Exception ex) {
ex.printStackTrace();
} finally {
//restore original key
}
}
appModul.getTypeOfPolicyBizCodeView3().executeQuery();
appModul.getTypeOfPolicyBizCodeView1().executeQuery();
}
return VisitResult.COMPLETE;
}
});
私のコードに何か問題がありますか? フィードバックをありがとう:)
更新: プロジェクトをデバッグしてみてください。この行で:
Object key = selection.next();
値はヌルです。どうしてか分かりません..
そして、私はこのエラーを受け取っています: 制約 "TYPE_OF_POLICY_BIZ_CODE_FK1" は、SQL ステートメント "DELETE FROM M_BUSSINESS MBussiness WHERE BIZ_CODE=:1" を使用したポスト操作 "削除" 中に違反しています。
ここで、値を削除するのではなく、追加しようとするため、再び混乱しました。私は間違っていますか?