< Anterior

Archivo customersearchAJAX.egl completado después de la lección 6

Este código es la versión del archivo customersearchAJAX.egl completado después de la lección 6. Si ve muchos errores marcados por símbolos X rojos en el archivo, asegúrese de que su código coincida con este código:
package jsfhandlers;

import eglderbydb.data.Customer;

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

	viewRoot UIViewRoot;
	lastNameInput STRING {TypeaheadFunction = suggestLastNames};
	allLastNames Customer[0];
	customerToDisplay Customer;

function onPreRender()
	get allLastNames with
		#sql{
			select
				LASTNAME
			from EGL.CUSTOMER
			group by
				LASTNAME
		};
end

	function suggestLastNames(typedCharacters STRING in) returns (STRING[])
		matchingLastNames STRING[0];
		oneCustomer Customer;
		oneCustomerName STRING;

		//Esta variable representa los caracteres que ha escrito el usuario.
		typedCharacters = StrLib.upperCase(typedCharacters);

		//Compare la entrada de usuario con los valores de la base de datos.
		for (counter INT from 1 to allLastNames.getSize())
			oneCustomer = allLastNames[counter];
			oneCustomerName = StrLib.upperCase(oneCustomer.LastName);

			if (StrLib.indexOf(oneCustomerName, typedCharacters) == 1)
				//Este valor comienza con los mismos caracteres.
				//Añada este valor a las sugerencias de tecleo anticipado.
				matchingLastNames.appendElement(oneCustomer.LastName);
			end

		end	
		return (matchingLastNames);
	end

	function displayCustomer()
		get customerToDisplay with
			#sql{
				select
					CUSTOMERID, FIRSTNAME, LASTNAME, PASSWORD, PHONE, 
					EMAILADDRESS, STREET, APARTMENT, CITY, "STATE", 
					POSTALCODE, DIRECTIONS
				from EGL.CUSTOMER
				where
					LASTNAME = :lastNameInput
			};
	end

end

Volver a Lección 6: Utilización del tecleo anticipado como solicitud al usuario.

< Anterior

Comentarios