When you use view criteria to be exposed in an <af:query/> component, it is sometimes weird that ADF allows you to change query operators. In this use case I define a view criteria using a BETWEEN clause on two dates.
When you create an <af:query/> component based on this criteria, you will see that it is rendered with operation 'between' as the selected operator. You do however have the possibility to change the operators. This actually makes no sense because you only need between.
You can change this behavior on the UI-hints tab of the view criteria editor.
When you run the application again, no operators are shown, but you can still insert two dates, still making it clear to the user that the search will be from - to.
This is a design-time solution. You can also manipulate this at run-time.
Run-time manipulation
For this you need to create the view object implementation class. In this class you then create a method that will show or hide the operators. By setting the "displayOperators" property of the view criteria, you can toggle between the show "InAdvancedMode" and show "never" mode.
You publish this method to the client and drop it as an <af:commandToolbarButton/> on your page. Last thing is to set partialSubmit attribute of the button and the partialtriggers attribute of the corresponding <af:query/> component.
Now you can toggle between the show operators by pushing the button.
When you create an <af:query/> component based on this criteria, you will see that it is rendered with operation 'between' as the selected operator. You do however have the possibility to change the operators. This actually makes no sense because you only need between.
You can change this behavior on the UI-hints tab of the view criteria editor.
When you run the application again, no operators are shown, but you can still insert two dates, still making it clear to the user that the search will be from - to.
This is a design-time solution. You can also manipulate this at run-time.
Run-time manipulation
For this you need to create the view object implementation class. In this class you then create a method that will show or hide the operators. By setting the "displayOperators" property of the view criteria, you can toggle between the show "InAdvancedMode" and show "never" mode.
1: public void toggleShowOperators(){
2: for (ViewCriteria vc:getAllViewCriterias()){
3: System.out.println(vc.getName());
4: System.out.println("displayOperators before change " + vc.getProperties().get("displayOperators"));
5: if (vc.getProperties().get("displayOperators")=="InAdvancedMode"){
6: vc.setProperty("displayOperators", "never");
7: }else
8: {
9: vc.setProperty("displayOperators", "InAdvancedMode");
10: }
11: System.out.println("displayOperators after change " + vc.getProperties().get("displayOperators"));
12: }
13: }
You publish this method to the client and drop it as an <af:commandToolbarButton/> on your page. Last thing is to set partialSubmit attribute of the button and the partialtriggers attribute of the corresponding <af:query/> component.
1: <af:toolbar id="t1">
2: <af:commandToolbarButton text="toggleShowOperators"
3: id="ctb1"
4: actionListener="#{bindings.toggleShowOperators.execute}"
5: disabled="#{!bindings.toggleShowOperators.enabled}"
6: partialSubmit="true"
7: />
8: </af:toolbar>
9: <af:panelHeader text="Employees" id="ph1">
10: <af:query id="qryId1" headerText="Search" disclosed="true"
11: value="#{bindings.EmployeesHireDateCriteriaQuery.queryDescriptor}"
12: model="#{bindings.EmployeesHireDateCriteriaQuery.queryModel}"
13: queryListener="#{bindings.EmployeesHireDateCriteriaQuery.processQuery}"
14: modeChangeVisible="false"
15: queryOperationListener="#{bindings.EmployeesHireDateCriteriaQuery.processQueryOperation}"
16: resultComponentId="::resId1"
17: partialTriggers="::ctb1"/>
18: </af:panelHeader>
Now you can toggle between the show operators by pushing the button.
Comments
i am stuck in same problem statement.