Until now, each JSF component you have added to Web pages has been bound to data from a single database table. If you are using a complex relational database, you may want to work with data from more than one table at a time.
In this lesson, you customize the results by displaying data from both the Customer table and the State table. In this way, the results show both the customer's name (from the Customer table) and the full name of the customer's state instead of the two-letter abbreviation (from the State table). You also manipulate the results by combining the customer's first name and last name into a full name field. The resulting data table looks like this:

function getOneState(state Statetable)
get state;
end
The stateTable record is defined
in the Statetable.egl file, so if you did not use code completion
to enter that function, you must organize your imports (Ctrl+Shift+O).Record customizedResult type basicRecord
fullName STRING {displayName = "Full Name"};
email STRING {displayName = "Email Address"};
stateName STRING {displayName = "State"};
end
Here is the complete code of the SearchLibrary.egl file. If you see any errors marked by red X symbols in the file, make sure your code matches the code in this file: Completed SearchLibrary.egl file after lesson 5.
allRecords customizedResult[0];
This
variable represents the new search results, based on the customized
record you just created. function generateCustomResults(passedResults Customer[])
allRecords.removeAll();
oneRecord customizedResult;
counter INT = 1;
state Statetable;
//loop once for each search result returned
while (counter <= (passedResults.getSize()))
oneRecord.fullName = passedResults[counter].FirstName ::
" " :: passedResults[counter].LastName;
oneRecord.email = passedResults[counter].EmailAddress;
state.STATE_ABBREV = passedResults[counter].state;
SearchLibrary.getOneState(state);
oneRecord.stateName = state.STATE_NAME;
allRecords.appendElement(oneRecord);
counter = counter + 1;
end
end
This function assembles the customized search results.
You must call this function at the end of the searchFunction() function.generateCustomResults (searchResults);
Here is the complete code of the customersearch.egl file. If you see any errors marked by red X symbols in the file, make sure your code matches the code in this file: Completed customersearch.egl file after lesson 5.
Now when you search for a customer, you see the customer's full name, email address, and full state name in the data table. The page looks like this:
