关于删除和应用 ADF 视图条件以编程方式查看对象的查询
Query regarding removing and applying ADF view criteria's to view object programmatically
我有几个关于查看标准的问题
- 删除几个应用的视图条件后,我是否需要执行查询
在应用相同或新的查看条件之前?
- 此外,在应用每个视图条件后,我是否需要执行查询?
- 如果我要应用的第一个查看条件是使用
testVO.applyViewCriteria(vc);
应用的,我是否需要先删除不需要的查看条件,或者是否会 applyViewCriteria(vc)
删除所有现有的查看条件?
我在下面的代码中试图做的是删除所有已应用的视图条件,然后应用我想要应用的新视图条件。
testVO.getViewCriteriaManager().removeApplyViewCriteriaName("findByvc1");
testVO.getViewCriteriaManager().removeApplyViewCriteriaName("findByvc2");
testVO.getViewCriteriaManager().removeApplyViewCriteriaName("findByvc3");
//testVO.executeQuery();
ViewCriteria vc = testVO.getViewCriteriaManager().getViewCriteria("findByvc1");
VariableValueManager vm = testVO.ensureVariableManager();
vm.setVariableValue("vc1Var", 123);
testVO.applyViewCriteria(vc);
//testVO.executeQuery();
ViewCriteria vc1 = testVO.getViewCriteriaManager().getViewCriteria("findByvc3");
vm.setVariableValue("vc3Var", "test");
testVO.applyViewCriteria(vc1, true);
testVO.executeQuery();
这是一篇文章,其中我讨论了如何在 Oracle ADF 中以编程方式应用视图标准:https://cedricleruth.com/how-to-apply-a-viewcriteria-programmatically-in-adf/ 代码摘录:
/**
* Apply view criteria named MyViewCriteria to it's ViewObject
* by getting it through the binding iterator MyViewObjectIterator
*/
public void applyViewCriteriaOnViewObjectByIteratorName(String MyViewCriteriaName, String MyViewObjectIteratorName) {
try {
//Get The viewObject from the iterator define in the current binding context
ViewObject vo = this.getViewObjectFromIteratorName(MyViewObjectIteratorName)
//Get all it's ViewCriteria using the ViewCriteriaManager of the ViewObject
ViewCriteriaManager vcm = vo.getViewCriteriaManager();
//Get the specified View Criteria
ViewCriteria vc = vcm.getViewCriteria(MyViewCriteriaName);
//Apply the ViewCriteria to the ViewObject
vo.applyViewCriteria(vc);
//Note: If you need to apply this view criteria on top of already applied view criteria
//without removing them you can add the following boolean parameter :
//vo.applyViewCriteria(vc,true);
//That's all you need if the iterator is set to be refresh after this
//If not you can force the ViewObject to execute by uncommenting the following :
//vo.executeQuery();
} catch (NullPointerException e) {
//Log and warn for null
//Often occur when there is an error in the provided attributes
//(MyViewCriteriaName, MyViewObjectIteratorName)
} catch (Exception e) {
//Log and warn for other exceptions - Should never be needed
}
/**
* Useful function to get ViewObject from IteratorName
* The iterator need to have a least one binding define in the current page
* In this gist it's a private but i advice setting it as a public static in an utility class available for the whole Controller
*/
private ViewObject getViewObjectFromIteratorName(String MyViewObjectIteratorName) {
ViewObject vo = null;
try {
DCBindingContainer bindings = (DCBindingContainer) BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding iterator = bindings.findIteratorBinding(MyViewObjectIteratorName);
vo = iterator.getViewObject();
} catch (NullPointerException e) {
//Log and warn for null
//Often occur when there is an error in the provided attributes
//or if the iterator doesn't have a least one binding define in the current page
}
return vo;
}
回答您的问题:
- 如果您的 vo 已经设置为刷新,则无需执行 executeQuery()。例如,如果您在迭代器上有一个 ppr。如果不是,你需要执行查询来强制刷新你的迭代器。
- 您不需要在每个 applyViewCriteria 之后执行查询,尤其是当您将第二个布尔参数设置为 true 时,它“在已应用的视图条件之上应用此视图条件”。它们将作为图层相互应用,并在您最后执行查询时设置。
- 如果您不将辅助布尔参数添加为 true,您的查看标准将是唯一应用的标准,所有其他标准将被自动删除。
我有几个关于查看标准的问题
- 删除几个应用的视图条件后,我是否需要执行查询 在应用相同或新的查看条件之前?
- 此外,在应用每个视图条件后,我是否需要执行查询?
- 如果我要应用的第一个查看条件是使用
testVO.applyViewCriteria(vc);
应用的,我是否需要先删除不需要的查看条件,或者是否会applyViewCriteria(vc)
删除所有现有的查看条件?
我在下面的代码中试图做的是删除所有已应用的视图条件,然后应用我想要应用的新视图条件。
testVO.getViewCriteriaManager().removeApplyViewCriteriaName("findByvc1");
testVO.getViewCriteriaManager().removeApplyViewCriteriaName("findByvc2");
testVO.getViewCriteriaManager().removeApplyViewCriteriaName("findByvc3");
//testVO.executeQuery();
ViewCriteria vc = testVO.getViewCriteriaManager().getViewCriteria("findByvc1");
VariableValueManager vm = testVO.ensureVariableManager();
vm.setVariableValue("vc1Var", 123);
testVO.applyViewCriteria(vc);
//testVO.executeQuery();
ViewCriteria vc1 = testVO.getViewCriteriaManager().getViewCriteria("findByvc3");
vm.setVariableValue("vc3Var", "test");
testVO.applyViewCriteria(vc1, true);
testVO.executeQuery();
这是一篇文章,其中我讨论了如何在 Oracle ADF 中以编程方式应用视图标准:https://cedricleruth.com/how-to-apply-a-viewcriteria-programmatically-in-adf/ 代码摘录:
/**
* Apply view criteria named MyViewCriteria to it's ViewObject
* by getting it through the binding iterator MyViewObjectIterator
*/
public void applyViewCriteriaOnViewObjectByIteratorName(String MyViewCriteriaName, String MyViewObjectIteratorName) {
try {
//Get The viewObject from the iterator define in the current binding context
ViewObject vo = this.getViewObjectFromIteratorName(MyViewObjectIteratorName)
//Get all it's ViewCriteria using the ViewCriteriaManager of the ViewObject
ViewCriteriaManager vcm = vo.getViewCriteriaManager();
//Get the specified View Criteria
ViewCriteria vc = vcm.getViewCriteria(MyViewCriteriaName);
//Apply the ViewCriteria to the ViewObject
vo.applyViewCriteria(vc);
//Note: If you need to apply this view criteria on top of already applied view criteria
//without removing them you can add the following boolean parameter :
//vo.applyViewCriteria(vc,true);
//That's all you need if the iterator is set to be refresh after this
//If not you can force the ViewObject to execute by uncommenting the following :
//vo.executeQuery();
} catch (NullPointerException e) {
//Log and warn for null
//Often occur when there is an error in the provided attributes
//(MyViewCriteriaName, MyViewObjectIteratorName)
} catch (Exception e) {
//Log and warn for other exceptions - Should never be needed
}
/**
* Useful function to get ViewObject from IteratorName
* The iterator need to have a least one binding define in the current page
* In this gist it's a private but i advice setting it as a public static in an utility class available for the whole Controller
*/
private ViewObject getViewObjectFromIteratorName(String MyViewObjectIteratorName) {
ViewObject vo = null;
try {
DCBindingContainer bindings = (DCBindingContainer) BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding iterator = bindings.findIteratorBinding(MyViewObjectIteratorName);
vo = iterator.getViewObject();
} catch (NullPointerException e) {
//Log and warn for null
//Often occur when there is an error in the provided attributes
//or if the iterator doesn't have a least one binding define in the current page
}
return vo;
}
回答您的问题:
- 如果您的 vo 已经设置为刷新,则无需执行 executeQuery()。例如,如果您在迭代器上有一个 ppr。如果不是,你需要执行查询来强制刷新你的迭代器。
- 您不需要在每个 applyViewCriteria 之后执行查询,尤其是当您将第二个布尔参数设置为 true 时,它“在已应用的视图条件之上应用此视图条件”。它们将作为图层相互应用,并在您最后执行查询时设置。
- 如果您不将辅助布尔参数添加为 true,您的查看标准将是唯一应用的标准,所有其他标准将被自动删除。