EGL JSF
ii EGL JSF
EGL JSF.. 1................. 1 1:.... 3 Web.......... 3........... 3........ 4......... 7 2:...... 7..... 7 SQL.... 8 JSF.... 10 Web.... 12......... 13 3: OR....... 14 OR... 14.15 OR..... 16......... 17 4: 18...... 18 JSF..... 19.... 20......... 22 5:...... 23...... 23.24.25......... 26................ 26............... 27 2 SearchLibrary.egl.. 27 2 customersearch.egl.. 28 3 SearchLibrary.egl.. 29 3 customersearch.egl.. 29 4 SearchLibrary.egl.. 30 4 customersearch.egl.. 31 5 SearchLibrary.egl.. 32 5 customersearch.egl.. 33 iii
iv EGL JSF
EGL JSF EGL JSF EGL ( ) v SQL v EGL v JSF 60 EGL ( ) EGL Hello world PDF EGL JSF EGL ( ) EGL JSF Web Web Web Web Web v SQL v EGL v JSF 1
60 EGL ( ) 2 (AND ) AND 2 (OR ) 2 EGL JSF
1: EGL EGL-JSF Web 1. Web 2. EGL 3. EGL JSF 4. EGL EGL 3 4 Web 1. EGLWeb WebContent 2. 3. Web Web 4. Web 5. ( ) customersearch.jsp 6. /EGLWeb/WebContent 7. 8. A_gray.htpl 9. 10. Customer Search 11. Enter 3 3 EGL 2 searchterms searchterms searchresults[] 1. EGL Customer Search EGL 2. 3. Customer 4. searchterms 5. 6. EGL Web EGL JSF 3
7. OK 8. Customer Search EGL 9. 10. Customer 11. searchresults 12. 13. EGL Web 14. OK 2 1. JSF 2. Customer Search searchterms - Customer 3. 4. 5. LastName State 6. 7. 8. Submit 9. 10. OK 11. 4 EGL JSF
12. Submit { } Enter Submit 1 13. Faces 14. Faces Submit 2 5 Customer(s) found. Search again? ( 5?) 15. Submit 2 searchresults - Customer[] 16. ( ) 17. 18. LastName EmailAddress State EGL JSF 5
19. 20. 6 EGL JSF
v EGL Web v EGL v Web EGL 2: 2: Web EGL EGL Web JSF 1. EGLWeb EGLSource EGL EGL JSF 7
2. EGL SearchLibrary 3. libraries EGL 4. EGL 5. EGL 6. package libraries; library SearchLibrary type BasicLibrary JSF SQL 1. SearchLibrary End function NameAndStateSearch_And(lname string in, state char(2) in, customer Customer[]) get customer; 3 v lname v state v customer lname state SQL 2. package libraries; import import eglderbyr7.data.customer; 3. get customer customer get customer customer SQL 4. get customer customer SQL SQL get customer EGL get customer SQL SQL 8 EGL JSF
get customer 5. from EGL.CUSTOMER Enter 1 6. from EGL.CUSTOMER where EGL.CUSTOMER.LAST_NAME like :lname and EGL.CUSTOMER."STATE" = :state EGL SQL EGL.CUSTOMER.LAST_NAME eglderbyr7.data :lname :state SQL EGL STATE state EGL SQL EGL ID EGL JSF 9
where SQL where defaultselectcondition 7. 8. Ctrl+G ( X ) 27 2 SearchLibrary.egl JSF 1. customersearch.jsp 2. 3. customersearch.jsp JSF ( ) searchresults Customer[0]; searchterms Customer; 4. 2 resultmessage char(80); numberofresults int; Web searchterms searchresults 5. JSF function searchfunction() searchterms.lastname = searchterms.lastname::"%"; SearchLibrary.NameAndStateSearch_And( searchterms.lastname, searchterms.state, searchresults); resultmessage = " customer(s) found."; numberofresults = searchresults.getsize(); 6. package jsfhandlers; import import libraries.searchlibrary; onprerer 7. JSF function onprerer() if (searchresults.getsize() == 0) resultmessage = "No customers found or no search criteria entered."; 8. onprererfunction JSF 10 EGL JSF
handler customersearch type JSFHandler {onconstructionfunction = onconstruction, onprererfunction = onprerer, view = "customersearch.jsp"} v searchterms searchresults Customer v searchfunction Submit NameAndStateSearch_And v Sm Sm% Smith Smiley v / 9. EGL JSF 11
customersearch.egl ( X ) 28 2 customersearch.egl Web JSF 1. customersearch.jsp 2. JSF 3. Submit numberofresults 4. resultmessage 5. Submit searchfunction() 12 EGL JSF
6. 7. a. customersearch.jsp b. Web LastName State Submit / LastName F State NJ AND OR State EGL v EGL v EGL JSF v JSF Web 3: OR EGL JSF 13
3: OR AND OR OR AND OR 1. SearchLibrary.egl 2. function NameAndStateSearch_Or(lname string in, state char(2) in, customer Customer[]) get customer with #sql{ select EGL.CUSTOMER.CUSTOMER_ID, EGL.CUSTOMER.FIRST_NAME, EGL.CUSTOMER.LAST_NAME, EGL.CUSTOMER.PASSWORD, EGL.CUSTOMER.PHONE, EGL.CUSTOMER.EMAIL_ADDRESS, EGL.CUSTOMER.STREET, EGL.CUSTOMER.APARTMENT, EGL.CUSTOMER.CITY, EGL.CUSTOMER."STATE", EGL.CUSTOMER.POSTALCODE, EGL.CUSTOMER.DIRECTIONS from EGL.CUSTOMER where EGL.CUSTOMER.LAST_NAME like :lname or EGL.CUSTOMER."STATE" = :state order by EGL.CUSTOMER.CUSTOMER_ID asc }; 14 EGL JSF
NameAndStateSearch_And where AND OR 3. 4. Java Ctrl+G 5. SearchLibrary.egl ( X ) 29 3 SearchLibrary.egl 2 1. customersearch.jsp 2. Enter 3. Faces 4. 5. 6. 7. 8. AND 9. AND 10. 11. 2 EGL JSF 15
OR 12. OR JSF 1. customersearch.egl 2. 16 EGL JSF
andor char(3); AND OR 3. searchfunction 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); resultmessage = "Customer(s) found. Search again?"; numberofresults = searchresults.getsize(); v andor (AND OR) v searchfunction if AND NameAndStateSearch_And NameAndStateSearch_Or 4. 5. customersearch.jsp 6. andor - char(3) 7. searchfunction() 8. 9. State customersearch.egl ( X ) 29 3 customersearch.egl 2 EGL JSF 17
v EGL OR v v OR JSF v 4: 4: State 1 1 1. SearchLibrary.egl 2. function getallcustomerstates(listofstates string[]) customers Customer[0]; counter int; get customers with #sql{ select EGL.CUSTOMER."STATE" from EGL.CUSTOMER group by EGL.CUSTOMER."STATE" order by EGL.CUSTOMER."STATE" asc }; listofstates.removeall(); for (counter from 1 to customers.getsize() by 1) listofstates.appelement(customers[counter].state); 3. 4. getallcustomerstates v getallcustomers getallcustomerstates Customer STATE 18 EGL JSF
v group by EGL.CUSTOMER."STATE" 1 v order by EGL.CUSTOMER."STATE" asc v for state SearchLibrary.egl ( X ) 30 4 SearchLibrary.egl JSF 1. customersearch.jsp 2. customersearch.jsp 3. andor char(3); customerstates string[0]; 4. Function onprerer() 1 SearchLibrary.getAllCustomerStates(customerStates); 5. 6. customersearch.egl ( ) EGL JSF 19
v customerstates 1 v onprerer customerstates getallcustomerstates customersearch.egl ( X ) 31 4 customersearch.egl JSF 2 EGL 20 EGL JSF
v customerstates v searchterms.state 1. customersearch.jsp 2. STATE Delete 3. Faces 4. STATE 5. searchterms - Customer 6. searchterms - Customer State - State 7. 8. #{customersearch.searchterms.state} searchterms State 9. <selectitems> <selectitems> JSF 10. <selectitems> 11. customerstates - string[] EGL JSF 21
12. OK customerstates searchterms 13. 14. Web v v JSF v Web v 5: 22 EGL JSF
5: Web JSF Customer State (Customer ) (2 ) (State ) EGL EGL 3 v email Customer v fullname Customer v State Customer State 1. SearchLibrary.egl 2. function getonestate(state Statetable) get state; statetable Statetable.egl 3. SearchLibrary.egl package libraries; import eglderbyr7.data.statetable; 4. Record customizedresult type basicrecord fullname string {displayname = "Full Name"}; email string {displayname = "Email Address"}; statename string {displayname = "State"}; EGL JSF 23
: customizedresult 5. 6. SearchLibrary.egl ( X ) 32 5 SearchLibrary.egl 1. customersearch.jsp 2. customersearch.jsp 3. JSF customerstates string[0]; allrecords customizedresult[0]; 4. JSF package jsfhandlers; import import libraries.customizedresult; 5. JSF function generatecustomresults(passedresults Customer[]) allrecords.removeall(); onerecord customizedresult; counter int = 1; state Statetable; // 1 while (counter <= (passedresults.getsize())) onerecord.fullname = passedresults[counter].firstname :: " " :: passedresults[counter].lastname; onerecord.email = passedresults[counter].emailaddress; state.stateabbrev = passedresults[counter].state; SearchLibrary.getOneState(state); onerecord.statename = state.statename; allrecords.appelement(onerecord); counter = counter + 1; searchfunction 6. JSF searchfunction generatecustomresults (searchresults); 7. JSF 1. 2. 24 EGL JSF
3. 4. 5. allrecords customersearch.egl ( X ) 33 5 customersearch.egl 1. customersearch.jsp 2. a. b. c. Delete 3. allrecords - customizedresult[] 4. ( ) 5. 6. 7. EGL JSF 25
FirstName LastName Fullname State 2 v v v JSF v Web v 5: EGL JSF v v EGL 26 EGL JSF
v EGL v EGL SQL v Java Server Faces Web v v v updatecustomer.jsp allcustomers.jsp v JavaServer Faces Web (Display dynamic information on Web pages with JavaServer Faces) Web (Design the layout and structure of your Web site) v 2 SearchLibrary.egl v 28 2 customersearch.egl v 29 3 SearchLibrary.egl v 29 3 customersearch.egl v 30 4 SearchLibrary.egl v 31 4 customersearch.egl v 32 5 SearchLibrary.egl v 33 5 customersearch.egl 2 SearchLibrary.egl 2 SearchLibrary.egl ( X ) package libraries; import eglderbyr7.data.customer; library SearchLibrary type BasicLibrary function NameAndStateSearch_And(lname string in, state char(2) in, customer Customer[]) get customer with #sql{ select EGL.CUSTOMER.CUSTOMER_ID, EGL.CUSTOMER.FIRST_NAME, EGL.CUSTOMER.LAST_NAME, EGL.CUSTOMER.PASSWORD, EGL.CUSTOMER.PHONE, EGL JSF 27
EGL.CUSTOMER.EMAIL_ADDRESS, EGL.CUSTOMER.STREET, EGL.CUSTOMER.APARTMENT, EGL.CUSTOMER.CITY, EGL.CUSTOMER."STATE", EGL.CUSTOMER.POSTALCODE, EGL.CUSTOMER.DIRECTIONS from EGL.CUSTOMER where EGL.CUSTOMER.LAST_NAME like :lname and EGL.CUSTOMER."STATE" = :state order by EGL.CUSTOMER.CUSTOMER_ID asc }; 7 2: 2 customersearch.egl 2 customersearch.egl ( X ) package jsfhandlers; import eglderbyr7.data.*; import libraries.searchlibrary; handler customersearch type JSFHandler {onconstructionfunction = onconstruction, onprererfunction = onprerer, view = "customersearch.jsp"} searchterms Customer; searchresults Customer[0]; resultmessage char(80); numberofresults int; function searchfunction() searchterms.lastname = searchterms.lastname::"%"; SearchLibrary.NameAndStateSearch_And( searchterms.lastname, searchterms.state, searchresults); resultmessage = " customer(s) found."; numberofresults = searchresults.getsize(); function onprerer() if (searchresults.getsize() == 0) resultmessage = "No customers found or no search criteria entered."; function onconstruction() 7 2: 28 EGL JSF
3 SearchLibrary.egl 3 SearchLibrary.egl ( X ) package libraries; import data.customer; library SearchLibrary type BasicLibrary function NameAndStateSearch_And(lname string in, state char(2) in, customer Customer[]) get customer with #sql{ select EGL.CUSTOMER.CUSTOMER_ID, EGL.CUSTOMER.FIRST_NAME, EGL.CUSTOMER.LAST_NAME, EGL.CUSTOMER.PASSWORD, EGL.CUSTOMER.PHONE, EGL.CUSTOMER.EMAIL_ADDRESS, EGL.CUSTOMER.STREET, EGL.CUSTOMER.APARTMENT, EGL.CUSTOMER.CITY, EGL.CUSTOMER."STATE", EGL.CUSTOMER.POSTALCODE, EGL.CUSTOMER.DIRECTIONS from EGL.CUSTOMER where EGL.CUSTOMER.LAST_NAME like :lname and EGL.CUSTOMER."STATE" = :state order by EGL.CUSTOMER.CUSTOMER_ID asc }; function NameAndStateSearch_Or(lname string in, state char(2) in, customer Customer[]) get customer with #sql{ select EGL.CUSTOMER.CUSTOMER_ID, EGL.CUSTOMER.FIRST_NAME, EGL.CUSTOMER.LAST_NAME, EGL.CUSTOMER.PASSWORD, EGL.CUSTOMER.PHONE, EGL.CUSTOMER.EMAIL_ADDRESS, EGL.CUSTOMER.STREET, EGL.CUSTOMER.APARTMENT, EGL.CUSTOMER.CITY, EGL.CUSTOMER."STATE", EGL.CUSTOMER.POSTALCODE, EGL.CUSTOMER.DIRECTIONS from EGL.CUSTOMER where EGL.CUSTOMER.LAST_NAME like :lname or EGL.CUSTOMER."STATE" = :state order by EGL.CUSTOMER.CUSTOMER_ID asc }; 14 3: OR 3 customersearch.egl 3 customersearch.egl ( X ) package jsfhandlers; import eglderbyr7.data.*; import libraries.searchlibrary; handler customersearch type JSFHandler EGL JSF 29
{onconstructionfunction = onconstruction, onprererfunction = onprerer, view = "customersearch.jsp"} searchterms Customer; searchresults Customer[0]; resultmessage char(80); numberofresults int; andor char(3); customerstates string[0]; 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); resultmessage = " customer(s) found."; numberofresults = searchresults.getsize(); function onprerer() if (searchresults.getsize() == 0) resultmessage = "No customers found or no data entered."; function onconstruction() 14 3: OR 4 SearchLibrary.egl 4 SearchLibrary.egl ( X ) package libraries; import data.customer; library SearchLibrary type BasicLibrary function NameAndStateSearch_And(lname string in, state char(2) in, customer Customer[]) get customer with #sql{ select EGL.CUSTOMER.CUSTOMER_ID, EGL.CUSTOMER.FIRST_NAME, EGL.CUSTOMER.LAST_NAME, EGL.CUSTOMER.PASSWORD, EGL.CUSTOMER.PHONE, EGL.CUSTOMER.EMAIL_ADDRESS, EGL.CUSTOMER.STREET, EGL.CUSTOMER.APARTMENT, EGL.CUSTOMER.CITY, EGL.CUSTOMER."STATE", EGL.CUSTOMER.POSTALCODE, EGL.CUSTOMER.DIRECTIONS from EGL.CUSTOMER where EGL.CUSTOMER.LAST_NAME like :lname and EGL.CUSTOMER."STATE" = :state order by 30 EGL JSF
}; EGL.CUSTOMER.CUSTOMER_ID asc function NameAndStateSearch_Or(lname string in, state char(2) in, customer Customer[]) get customer with #sql{ select EGL.CUSTOMER.CUSTOMER_ID, EGL.CUSTOMER.FIRST_NAME, EGL.CUSTOMER.LAST_NAME, EGL.CUSTOMER.PASSWORD, EGL.CUSTOMER.PHONE, EGL.CUSTOMER.EMAIL_ADDRESS, EGL.CUSTOMER.STREET, EGL.CUSTOMER.APARTMENT, EGL.CUSTOMER.CITY, EGL.CUSTOMER."STATE", EGL.CUSTOMER.POSTALCODE, EGL.CUSTOMER.DIRECTIONS from EGL.CUSTOMER where EGL.CUSTOMER.LAST_NAME like :lname OR EGL.CUSTOMER."STATE" = :state order by EGL.CUSTOMER.CUSTOMER_ID asc }; function getallcustomerstates(listofstates string[]) customers Customer[0]; counter int; get customers with #sql{ select EGL.CUSTOMER."STATE" from EGL.CUSTOMER group by EGL.CUSTOMER."STATE" order by EGL.CUSTOMER."STATE" asc }; listofstates.removeall(); for (counter from 1 to customers.getsize() by 1) listofstates.appelement(customers[counter].state); 18 4: 4 customersearch.egl 4 customersearch.egl ( X ) package jsfhandlers; import eglderbyr7.data.*; import libraries.searchlibrary; handler customersearch type JSFHandler {onconstructionfunction = onconstruction, onprererfunction = onprerer, view = "customersearch.jsp"} searchterms Customer; searchresults Customer[0]; resultmessage char(80); numberofresults int; andor char(3); customerstates Customer[]; EGL JSF 31
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); resultmessage = "Customer(s)found. Search again?"; numberofresults = syslib.size(searchresults); function onprerer() SearchLibrary.getAllCustomerStates(customerStates); if (searchresults.getsize() == 0) resultmessage = "No customers found or no search criteria entered."; function onconstruction() 18 4: 5 SearchLibrary.egl 5 SearchLibrary.egl ( X ) package libraries; import data.customer; library SearchLibrary type BasicLibrary function NameAndStateSearch_And(lname string in, state char(2) in, customer Customer[]) get customer with #sql{ select EGL.CUSTOMER.CUSTOMER_ID, EGL.CUSTOMER.FIRST_NAME, EGL.CUSTOMER.LAST_NAME, EGL.CUSTOMER.PASSWORD, EGL.CUSTOMER.PHONE, EGL.CUSTOMER.EMAIL_ADDRESS, EGL.CUSTOMER.STREET, EGL.CUSTOMER.APARTMENT, EGL.CUSTOMER.CITY, EGL.CUSTOMER."STATE", EGL.CUSTOMER.POSTALCODE, EGL.CUSTOMER.DIRECTIONS from EGL.CUSTOMER where EGL.CUSTOMER.LAST_NAME like :lname and EGL.CUSTOMER."STATE" = :state order by EGL.CUSTOMER.CUSTOMER_ID asc }; function NameAndStateSearch_Or(lname string in, state char(2) in, customer Customer[]) get customer with #sql{ select EGL.CUSTOMER.CUSTOMER_ID, EGL.CUSTOMER.FIRST_NAME, EGL.CUSTOMER.LAST_NAME, EGL.CUSTOMER.PASSWORD, EGL.CUSTOMER.PHONE, EGL.CUSTOMER.EMAIL_ADDRESS, EGL.CUSTOMER.STREET, 32 EGL JSF
EGL.CUSTOMER.APARTMENT, EGL.CUSTOMER.CITY, EGL.CUSTOMER."STATE", EGL.CUSTOMER.POSTALCODE, EGL.CUSTOMER.DIRECTIONS from EGL.CUSTOMER where EGL.CUSTOMER.LAST_NAME like :lname OR EGL.CUSTOMER."STATE" = :state order by EGL.CUSTOMER.CUSTOMER_ID asc }; function getallcustomerstates(listofstates string[]) customers Customer[0]; counter int; get customers with #sql{ select EGL.CUSTOMER."STATE" from EGL.CUSTOMER group by EGL.CUSTOMER."STATE" order by EGL.CUSTOMER."STATE" asc }; listofstates.removeall(); for (counter from 1 to customers.getsize() by 1) listofstates.appelement(customers[counter].state); Function getonestate(state Statetable) get state; Record customizedresult type basicrecord fullname string {displayname = "Full Name"}; email string {displayname = "Email Address"}; statename string {displayname = "State"}; 23 5: 5 customersearch.egl 5 customersearch.egl ( X ) package jsfhandlers; import eglderbyr7.data.*; import libraries.searchlibrary; import libraries.customizedresult; handler customersearch type JSFHandler {onconstructionfunction = onconstruction, onprererfunction = onprerer, view = "customersearch.jsp"} searchterms Customer; searchresults Customer[0]; resultmessage char(80); numberofresults int; andor char(3); customerstates Customer[]; EGL JSF 33
allrecords customizedresult[]; 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); resultmessage = "Customer(s)found. Search again?"; numberofresults = syslib.size(searchresults); generatecustomresults (searchresults); function onprerer() SearchLibrary.getAllCustomerStates(customerStates); if (searchresults.getsize() == 0) resultmessage = "No customers found or no search criteria entered."; function onconstruction() 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.stateabbrev = passedresults[counter].state; SearchLibrary.getOneState(state); onerecord.statename = state.statename; allrecords.appelement(onerecord); counter = counter + 1; 23 5: 34 EGL JSF