JDev & ADF Goodies

6. January 2012

JDEV: af:query hide some attributes from query panel but show them in the result table

An interesting question came up today in the OTN JDev forum. The use case is to use an af:query component to qurey a db table, but make some of the attributes available in the table invisible in the query panel.
You can archive this using viewCriteria, but in this case you still can reach the other attributes in advanced mode.
The way to go is to make the attribute which you want to hidenot queryable in the view definition. For this we open the VO and select the attribute node.

Queryable Attribute in a VO

Queryable Attribute in a VO

Here we remove the check mark from the ‘Queryable’ checkbox like I did for the JobId attribute in the picture below

Not queryable attribute in a VO

Not queryable attribute in a VO

Now when we use this VO in a af:query component we see all queryable attributes but not the ones where we removed the check box. In the sample I removed the checkmark for JobId, ManagerId and DepartmentId in the EmployeesView. The resulting query panel which I build using the ‘All Queriable Attributes’ from the ‘Names Criteria’ section of the EmployeesView

Build Query Panel

Build Query Panel

looks like the picture below in the running application. As you can see JobId, ManagerId and DepartmentId are not part of the query panel but can be seen the result table.

Query Panel

Query Panel

In advanced mode you can’t add the missing attributes

Query Panel Advanced Mode

Query Panel Advanced Mode

You can remove the checkbox from the EO too, but this would mean that no VO build on this EO can query the attributes. If you only remove the checkbox in the VO you can build an other VO based on the same EO and make all attributes queriable.

You can download the sample workspace, build with JDev 11.1.2.1.0 and depending on hte HR db schema, from here: BlogCascadingTable.zip
Please rename the file to ‘.zip’ after downloading it!

Advertisement

3 Comments »

  1. Hi.

    Nice post.

    I think this article could be good for this topic, it deals about show / hide controls of the af:Query

    http://www.notjustjava.com/2011/12/cool-tips-to-showhide-components-of-the-query-control-of-adf/

    Comment by Juan — 11. January 2012 @ 12:12 | Reply

    • Juan,
      Thanks for pointing this (your) blog out. Did not know your blog about this issue. Keep posting…

      Timo

      Comment by Timo Hahn — 11. January 2012 @ 15:15 | Reply

  2. Hi Timo,

    at first, nice post! But I have another option (ganz nach dem Motto “Viele Wege führen nach Rom”).

    For the ViewCriteria I define the “Search Region Mode” with “Basic” and “Show Operators” with “in Basic mode” (because this is one killing feature…). In the UI we set the “modeChangeVisible” to “false” for the af:query-component. Thats all. Now the User can change the operators but can not add new fields.

    The two screenshots to explain the better:
    http://img823.imageshack.us/img823/5798/afquery01.png
    http://img714.imageshack.us/img714/5944/afquery02.png

    best regards

    Martin

    Comment by Martin — 16. January 2012 @ 20:20 | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 45 other followers