Introduction to Query Components

12-4 Web User Interface Developers Guide for Oracle Application Development Framework Figure 12–3 Class Diagram for QueryModel To create the model classes: 1. Create implementations of each of the interface classes shown in Figure 12–3 . Implement one QueryModel class and then a QueryDescriptor class with appropriate criteria operators and values for each system-seeded search. For example implementations of the different model classes for a query, see the classes located in the oracle.adfdemo.view.query.rich package of the ADF Faces sample application.

2. Create a QueryListener handler method on a managed bean that listens for the

QueryEvent event this will be referenced by a button on the query component. This listener will invoke the proper APIs in the QueryModel to execute the query. Example 12–1 shows the listener method of a basic QueryListener implementation that constructs a String representation of the search criteria. This String is then displayed as the search result. Note: If your query uses composition for example, ConjunctionCriterion 1...n with AttributeCriterionConjunctionCriterion, this relationship is not enforced by the abstract interfaces. Your implementation must decide whether to use composition over association, and determine how the lifecyle of these objects are managed. Using Query Components 12-5 Example 12–1 A QueryListener Handler Method public void processQueryQueryEvent event { DemoQueryDescriptor descriptor = DemoQueryDescriptor event.getDescriptor; String sqlString = descriptor.getSavedSearchDef.toString; setSqlStringsqlString; } Query component has a refresh method on the UIXQuery component. This method should be called when the model definition changes and the query component need to be refreshed i.e., all its children removed and recreated. When a new criterion is added to the QueryDescriptor or an existing one is removed, if the underlying model returns a different collection of criterion objects than what the component subtree expects, then this method should be called. QueryOperationListener, QueryListener, and ActionListener should all call this method. The query component itself will be flushed at the end of the Invoke Application Phase. This method is a no-op when called during the Render Response Phase. To better understand what your implementations must accomplish, Table 12–1 and Table 12–2 map the functionality found in the UI component shown in Figure 12–4 with the corresponding interface. Figure 12–4 Query Component and Associated Popup Dialog Table 12–1 shows UI artifacts rendered for the query component, the associated class, class property, and methods used by the artifact. 12-6 Web User Interface Developers Guide for Oracle Application Development Framework Table 12–1 Query UI Artifacts and Associated Model Class Operations and Properties UI Artifact Class PropertyMethods Used Comments 1 Search panel The QueryDescriptor instance provides the items displayed in the panel. Based on a saved search. 2 Disclosure icon Opens or closes the search panel 3 Match type radio button Available through the getConjunction method on the ConjunctionCriterion class. Displays the default conjunction to use between search fields, when a query is performed. If a default is set, and it is the same for all search fields, it appears selected. If the search fields are configured such that a mix of different conjunctions must be used between them, then a value may not be selected on the UI. For example, if the All conjunction type is used between all the search fields, then All appears selected. If it is a mix of All and Any, then none of the radio buttons appears selected. The Match Type will be read only if the conjunctionReadOnly property is set to true. Its not rendered at all when the displayMode attribute is set to simple.