JHeadstart – Querying a Master for its Details – for example: search Departments with at least one Clerk

JHeadstart can generate a number of powerful search facilities, such as the Quick Search widget and Advanced Search area. It supports several different serach operators such as contains, like, smaller and greater than, between, begins with, ends with etc. The Search Items can have associated select-lists , radio-groups and lists of values. All ViewObject attributes that are queryable can be selected as Search Fields in the generated application.

In one of my applications, the need arose to be able to search records that had details conforming to some search criterium. For example: search Departments that had at least one CLERK child record. Or in my case, Companies that had someone called something like ‘Brow’ working for them. Although it cannot be generated – as far as I can tell – we can come very close and only a very small manual step is required to implement this functionaliy. In this article I will explain how it can be done.

First of all, add the following conditiion to the View Object you want to query one:

and ( nvl(:1,'null') = 'null' or exists ( select 1 from emp e where e.deptno = dept.deptno and lower(ename) like  lower('%'||:2 ||'%'))
JHeadstart - Querying a Master for its Details - for example: search Departments with at least one Clerk searchDetailVO

Secondly, add two Query Bind Parameters to Group definition in the Application Structure File:

${param.EmployeeName},${param.EmployeeName}

Make sure that the Group has an Advanced Search area, by setting the Group property Advanced Search to either samePage or separatePage.

JHeadstart - Querying a Master for its Details - for example: search Departments with at least one Clerk searchDetailAppstruct

Finally, after generating the application, we need to apply this post-generation step in the Advanced Search area:

add a messageTextInput element like this:

<messageTextInput id="EmployeeName" name="EmployeeName" text="${param.EmployeeName}" promptAndAccessKey="&amp;Employee Name"

also add the new search item to the list of items to ignore when it comes to the warning about changed fields:

<script text="addToIgnoreChangedFields(['FindDepartments1Deptno','FindDepartments1Dname','FindDepartments1Loc','EmployeeName',]);"/>

 

JHeadstart - Querying a Master for its Details - for example: search Departments with at least one Clerk SearchDetailpostGenUIX

Now run the application.

 

 

JHeadstart - Querying a Master for its Details - for example: search Departments with at least one Clerk searchDetailRuntime

 

In this example, I have searched for all Departments that contain an Employee whose name contains the string ARK. Department 10 is returned, because it contains Mr. CLARK.