![](/img/trans.png)
[英]Setting Non English Characters on OutputText from backing bean in ADF
[英]Proper way to execute a query in a backing bean and update a table in ADF
我有一個搜索按鈕,它應該執行一個支持 bean 方法,執行一個查詢,然后刷新表。 我正在更改過程中查詢的綁定參數。 這樣做的最佳方法是什么?
謝謝!
最好的方法是遵循MVC模型。 為此,只需使用此算法:
創建視圖對象接口的實現。 在這里,您可以使用將傳遞給查詢的參數定義方法。 為此,只需轉到 Viewobject 定義-“Java 選項卡”-“Java 類”編輯並選中“生成視圖對象類:YourViewObjectViewImpl”和“包含綁定變量訪問器”,然后按確定按鈕。 找出類 YourViewObjectViewImpl.java 並使用您需要的參數實現方法。 例如,您需要 2 個參數來刷新您的 VO:
public class YourViewObjectViewImpl extends ViewObjectImpl {
// Generated method
public void setA(Long value) {
setNamedWhereClauseParam(value);
}
// Generated method
public void setB(Long value) {
setNamedWhereClauseParam(value);
}
// Your custom method
public void refreshQuery(long a, long b) {
this.clearCache();
setA(a);
setB(b);
this.executeQuery();
}
}
現在你需要讓這個方法對 ViewController 可見。 在 ViewObject 定義的 java 選項卡中,按“客戶端界面”上的編輯,然后將穿梭刷新查詢方法移到右側。 按確定。 現在 Jdev 生成兩個類,它們將幫助您使您的方法在 ViewController 項目中可見。
下一步是在頁面定義綁定中定義您的 refreshQuery。 轉到頁面定義並按“綁定”面板上的 + 按鈕。 從列表中選擇 methodAction。 從 AppModuleDataControl 中選擇 ViewObject 並在操作組合框中選擇 refreshQuery 方法。 在帶有參數的表中,您可以使用表達式語言定義值。 例如 #{viewScope.myBean.a} 和 #{viewScope.myBean.b} 按確定。
現在您可以從 bean 執行此方法,例如:
public class MyBean {
public Long a = 0;
public Long b = 0;
public void refresh() {
a = 1;
b = 2;
BindingContext bc = BindingContext.getCurrent();
DCBindingContainer dcbc = (DCBindingContainer)bc.getCurrentBindingsEntry();
dcbc.getOperationBinding("refreshQuery");
dcbc.execute();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.