Conditionally displaying search form parameters

ADF helps you to build search forms declaratively using model-driven af:query and af:quickQuery components. To learn more about this topic, please refer Chapter 26 Creating ADF Databound Search Forms in Fusion Dev. Guide.

If you use ADF Business Components for building your business services, ViewCriteria defined on your ViewObject act as the model for the af:query component. af:query component (backed up with ViewCriteria) is smart enough to address most of the common use cases declaratively. However there may be some use case scenarios, where developers need to go beyond the declarative development approach and dirty their hands a bit:) One such scenario is displaying search form prameters, conditionally. In other words, parameters in the query panel needs to be displayed based on certain conditions. Let me try explaining a possible solution for this use case. Please remember that each query parameter displayed in af:query is modeled by a ViewCrieteriaIteminstance. Apparently, you can make use of the ViewCriteriaItemHints to control the display properties. Following piece of code may help you to hide the ViewCriteriaItem programmatically.
Hey, hang on, I’m not finished!

From Fusion Developer's Guide:
If you are changing the value of a view criteria item programmatically, you must invoke the ViewCriteria.saveState() method to prevent the searchRegion binding from resetting the value of the view criteria item to the value that was specified at design time.

So you may need to call ViewCriteria.saveState() to persist the changes.

That’s sit back and relax!

You can download the sample workspace from here. This example illustrates the above mentioned use case -i.e.: hiding search form parameters at runtime. This sample has two pages department.jspx and employee.jspx. User can navigate from department page to employee search page. The employee.jspx is hosting a task flow that in turn contains a query panel + result table. Department Id displayed inside the query panel of the employee page will be hidden from the user if he/she navigates from department page after selecting a specific department (which makes sense too).
[Runs with Oracle JDeveloper 11g R1 PS1 + HR Schema]


  1. Hi Jobinesh,

    Very good effort.Do you have any Idea if I want to change the label of the control in search block. In More details - let's have a scenarion below-
    I have my view object. one of the attribute of my view is DOJ(date of joining).I have created some bind variable.One variable name fromDOJ another one toDOJ. which is binded with DOJ in my query. one for ONORAFTER another for ONORBEFORE. Now I will have two filed in my search block if i create a query criteria with this two bind variable. But in both cases my label will be DOJ, I fi change the label from attribute property to Date of Joining then in both field label will be Date of Joining. But I want in one case it should be "From Date of Joining" and for other one I want "To Date of Joining". Any point of hints would be great.
    Thanks in advance.

  2. Sorry, I didn't get the question clearly. Sample that I tried working as expected, may be I'm missing something. Could you please pass a simple test case to me

    1. hi,
      How to remove attribute label in view criteria

  3. Dear Jobnish,

    Already I have send you a detailed mail with my requirement. Please have a look and provide your valuable input.


  4. Dear Jobinesh,
    The requirement I asked, it is done. You don't need to do any code. here is the procedure I followed -
    Create two more attribute in your view from entity and both the attribute should point to your entity date field.
    Now open the property window for newly added attribute in your view. Provide the label text value as you want for both attribute.
    Next when you create your view criteria - point your from date variable to one of the newly added attribute and the same for to Date too. Now you create your af:query you will get different label that is provided for 2 newly added attribute. If not clear let me know I will send you step-by-step screen shot. And the same you can update in one of the oracle blog.
    By the way can we outsider add our found or rnd in any of oracle blog that may help to some other developer. Actually I have number of topic to pussh like DB generated Menu/Context Menu/Train Control/Accordian Control and many more. Also How to implement Lock like oracle form in ADF.
    My Mail ID I feel it is already with you.

    Thanks & Regards

  5. great Subu, thanks for the update!
    btw, you can start your own blog on ADF, if interested. Once you start blogging on ADF, please add your entry here Happy blogging :)


Post a Comment