Create table with ADF query panel

This article gives a step-by-step introduction on how to create a simple table with ADF query panel.

We have a BooksVO with attributes Id, Name, PurchadsingDate and Owner.

Create a view criteria BooksViewCriteria with items Id, Name, PurchadsingDate and Owner, in which Id and Name are selectively required.

Create a new JSP page Page6.jsf on which we will create the table:

Expand the BooksAppModuleDataControl in Data Controls, drag the view criteria BooksViewCriteria and drop into the jsf file.

In the Create tab, select Query → ADF Query Panel With Table.

In Create Table, check Enable Sorting and Enable Filtering. Click on OK.

After creating the table successfully, we can see the design of the page. There are a query panel and a table on the page.

Drag Page6 to adfc-config.xml. Right click on the blank and select Run. 

After it runs successfully, click on the target URL and open the page.

We can see from the page that BooksViewCriteria is set as the default Saved Search.

Since  Id and Name are set as selectively required in the view criteria, they are marked as "At least one is required."

Test basic search:

Give the Id 1 and click on search, the table shows the book of Id 1.

Test Advanced Search:

Navigate to Advanced Search and we can find there are more operators to choose.

Test QBE:

Type the keyword you want to filter in the input text box and enter to get the filter results.

How the query works?

Navigate to the Bindings of Page6.jsf we can find  BooksViewCriteraQuery is created as a search region automatically and linked to the VO when we create the table using the view BooksViewCriteria.

Code snippet of <af: query> and <af: table>:

<af:panelHeader text="Books" id="ph1">

    <af:query id="qryId1" headerText="Search" disclosed="true"

              value="#{bindings.BooksViewCriteriaQuery.queryDescriptor}"

              model="#{bindings.BooksViewCriteriaQuery.queryModel}"

              queryListener="#{bindings.BooksViewCriteriaQuery.processQuery}"

              queryOperationListener="#{bindings.BooksViewCriteriaQuery.processQueryOperation}"

              resultComponentId="::resId1"/>

</af:panelHeader>

<af:table value="#{bindings.BooksView1.collectionModel}" var="row"

          rows="#{bindings.BooksView1.rangeSize}"

          emptyText="#{bindings.BooksView1.viewable ? 'No data to display.' : 'Access Denied.'}"

          rowBandingInterval="0"

          selectedRowKeys="#{bindings.BooksView1.collectionModel.selectedRow}"

          selectionListener="#{bindings.BooksView1.collectionModel.makeCurrent}"

          rowSelection="single" fetchSize="#{bindings.BooksView1.rangeSize}"

          filterModel="#{bindings.BooksViewCriteriaQuery.queryDescriptor}"

          filterVisible="true"

          queryListener="#{bindings.BooksViewCriteriaQuery.processQuery}"

          varStatus="vs" id="resId1">

    ...

</af:table>

猜你喜欢

转载自blog.csdn.net/bettyHHUC/article/details/89705274