You are on page 1of 24

12

Building a Query Page

Copyright © 2007, Oracle. All rights reserved.


Objectives

After completing this lesson, you should be able to do


the following:
• Create a parameterized named query
• Include a named query in a data control
• Build a parameterized form
• Display the results of the query
• Use Expression Language to customize behavior

12-2 Copyright © 2007, Oracle. All rights reserved.


The Search Page

1
3

12-3 Copyright © 2007, Oracle. All rights reserved.


Using a Parameterized Named Query

• Choices with named queries


– Method
Button
Link
– Parameter Form
• Requires a return value

12-4 Copyright © 2007, Oracle. All rights reserved.


Defining Parameters for Named Queries

12-5 Copyright © 2007, Oracle. All rights reserved.


The Query Expression

The query expression must have two arguments and


one operator:
• First argument: Query Key Attribute
• Operator: Less Than, Like, Equal, and so on
• Second argument: Parameter, Literal, or Query
Key
@NamedQuery(name =
"ServiceRequest.searchServiceRequests", query =
"select o from ServiceRequest o " + "where
upper(o.status) LIKE :p_status and
upper(o.problemDescription) LIKE :p_desc")
}

12-6 Copyright © 2007, Oracle. All rights reserved.


Moving the Named Query Forward

To add the named query to the data control:


1. Edit the Session Facade and select the new named
query.
2. Re-create the data control from the Session Bean.

12-7 Copyright © 2007, Oracle. All rights reserved.


Adding the Named Query
to the Session Facade

Select the named query to add to the Session Facade.


JDeveloper creates the code in the facade to match the
named-query definition.

12-8 Copyright © 2007, Oracle. All rights reserved.


Re-Creating the Data Control

To expose the Session Facade code to the data


control, right-click the Session Bean and use the
shortcut menu option.

12-9 Copyright © 2007, Oracle. All rights reserved.


Building a Parameterized Form

Drag the named query to the page as an ADF


Parameter Form.

12-10 Copyright © 2007, Oracle. All rights reserved.


Defining Display Properties of Parameters

Define the display properties of the parameters.

12-11 Copyright © 2007, Oracle. All rights reserved.


Elements of an ADF Parameter Form

Parameter Form includes:


• Item for each parameter
• Prompt for each item

• Button to execute the method

12-12 Copyright © 2007, Oracle. All rights reserved.


Using the Expression Language Editor

12-13 Copyright © 2007, Oracle. All rights reserved.


Editing Bindings

• To edit bindings:
– From the page: In the Visual Editor, right-click the
component and select Edit Binding.
– From the page definition file: In the structure pane,
double-click the binding.
• Each type of binding has an editor dialog box.

12-14 Copyright © 2007, Oracle. All rights reserved.


Binding a Button or Link to a Method

Use the Action Binding Editor to set the Value


property:
• From the page: In the Visual Editor, right-click the
component and select Edit Binding.
• From the page definition file: In the Structure
window, double-click the binding.

12-15 Copyright © 2007, Oracle. All rights reserved.


Working with the Binding

Page definition structure:


• Parameters
• Variables
• Bindings
• Other method attributes

12-16 Copyright © 2007, Oracle. All rights reserved.


Using the Return to Display the Results

• Use the method return to create the table.


• Data Bindings are automatic.
• Tables can be read-only or not.

12-17 Copyright © 2007, Oracle. All rights reserved.


Display the Results

In the Edit Tables dialog box:


• Change component type • Enable selecting
• Change labels • Enable sorting
• Resequence items

12-18 Copyright © 2007, Oracle. All rights reserved.


Using EL to Customize Search Results

• Use the bindings node to refine the NamedData


values.
• If a value is null, insert a percent (%) as a wildcard for
the parameter, so that all records are returned.

12-19 Copyright © 2007, Oracle. All rights reserved.


Setting a Refresh Condition

• Use Page Definition to add new executables.


• Use the RefreshCondition property to determine
when the table data is displayed or redisplayed.
• The postback condition occurs when the user
interacts with the UI, not when a page is first
rendered.

12-20 Copyright © 2007, Oracle. All rights reserved.


12-21 Copyright © 2007, Oracle. All rights reserved.
Summary

In this lesson, you should have learned how to:


• Create a parameterized named query
• Include a named query in a data control
• Build a parameterized form
• Display the results of the query
• Use Expression Language to customize behavior

12-22 Copyright © 2007, Oracle. All rights reserved.


Practice Overview:
Creating a Search Form

This practice covers the following topics:


• Creating a parameterized form
• Modifying the bindings
• Displaying the results in a separate table

12-23 Copyright © 2007, Oracle. All rights reserved.


12-24 Copyright © 2007, Oracle. All rights reserved.