< Previous | Next >

Completed customersearch.egl file after lesson 3

This code is the version of the customersearch.egl file completed after lesson 3. If you see any errors marked by red X symbols in the file, make sure your code matches this code:
package jsfhandlers;

import com.ibm.egl.jsf.UIViewRoot;
import eglderbydb.data.*;
import libraries.SearchLibrary;


handler customersearch type JSFHandler
	{onConstructionFunction = onConstruction, 
	 onPrerenderFunction = onPrerender, 
 	 view = "updatecustomer.jsp",
 	 viewRootVar = viewRoot} 

	viewRoot UIViewRoot;
	searchTerms Customer;
	searchResults Customer[0];
	resultMessage CHAR(80); 
	numberOfResults INT; 
	andOr CHAR(3);

	// Function Declarations
	function onConstruction()
	end
	
	function onPrerender()
		if (searchResults.getSize() == 0)
			resultMessage = "No customers found or no search criteria entered.";
		end
	end

	function searchFunction()
		searchTerms.LastName = searchTerms.LastName + "%";
		
		if (andOr == "AND")
			SearchLibrary.NameAndStateSearch_And(
				searchTerms.LastName,
				searchTerms.State, searchResults);
		else
			SearchLibrary.NameAndStateSearch_Or(
				searchTerms.LastName,
				searchTerms.State, searchResults);
		end
		
		resultMessage = " customer(s) found.";
		numberOfResults = searchResults.getSize(); 
	end
end

Return to Lesson 3: Use the OR search condition.

< Previous | Next >

Feedback