Chapter 17

Online Employee Phonebook


CONTENTS


tel e phone \tel'e-fon'\ n: an electronic device or system for sound reception or reproduction at a distance

Introduction

Welcome to your fifth sample intranet application. If you thought the last program-the Online In/Out Board-was simple, wait until you see this application. This is the Online Employee Phonebook.

This read-only application displays the phone numbers of employees in a scrolling list. This is useful for all employees to look up the phone numbers of their coworkers.

This chapter will cover the following topics in regards to the Online Employee Phonebook application:

This four step format will be used throughout all of the sample application chapters. Hopefully, it will provide you with valuable insight and ideas for creating your own intranet applications.

Application Design

This application, like the last, is one of the simpler applications in the book. Once this application has been connected to a data source, it will present the user with a list of all the employees on file, as well as their phone numbers and names formatted in an attractive manner.

Figure 17.1 is the proposed user interface for the Online Employee Phonebook program.

Figure 17.1 : The Online Employee Phonebook user interface.

The interface will utilize a JifTextArea component to display employees and their phone numbers, and a single Refresh button to refresh the list.

The list needs to be refreshed periodically. The Refresh button is just the ticket. By pressing that button, the user initiates the process of reloading the JifTextArea.

Database Design

This application utilizes the employee table that was defined in Chapter 13, "Employee Files." There really is nothing new here. The application retrieves the rows from the table and displays the data.

Implementation

In the rest of this chapter I will discuss the implementation of the Online Employee Phonebook program. I'll first discuss the user interface and how it was created. Secondly, I'll discuss the database access used in the program. Finally, I'll cover any programming pitfalls that came up during the application construction.

Each sample application in this book uses a different approach to developing the user interface. This variety will show you the different ways you can go about doing your own interfaces. Hopefully, you will get a nice cross-section of many different styles and choose the one that suits you the best.

User Interface

To achieve the design goal presented above, you do not need special user interface components. The stock BorderLayout is sufficient. You'll also employ the JifTextArea class and a button.

<> the follo17.1 isial user interfaon construrfaderface fo JifTex                    alsBorderL() );76CEgr76CEgr        alsJifTex( 15, 40 );76CEgr        add(, &C prer/A>, &fulals, & The Re&A>, & );76CEgr        saveBd a buI'lthe ();gr76CEgr        p.add(, &SerLh/A>, &fulp );76CEgr    }tArea BorderLayout.

the JifTextArea was crclassplnteesused inc prers one of rderL list. Thioingulalse Emplaeir pling l Therup duro >Figure, Here yo you sahoughThi The explasst, st ofg Co needfi of allspntection. Ying ngle Refresh bually>Jicient. Yoranet nas trie s new:>Us In ordewill stutompplcou dif applica one oing resh buw it. By edfully,n, I' andf allShat resh buttongle Re list. resh buallu'llu thlthe dction. Overupreloading thesaveRec I()tArea Figur2 i ou Tees sfresh rderLerest of this applicagram.

Figur2 17.1 : Hlasleloadingngle RefBd a btion. Yinfwampoying ngle Refresh butto' ab simacel insup, wannl you tthe databeen colication has en theirefr liP> To achieimpftin gor prodingdefaiffi thebeen coTo0000>Dat()tArea Dat                                         ;                *=576CEgr//****************************************************************************=576CEgr76CEgr    pube a void76CEgr    been coTo0000>Dat()t6CEgr    {76CEgr        //    Cam.Dat()t6CEgr    {76sp;   {76CEgr   &nbsEncationata rasleloadingngp;  //    Cam., &SerLh/A>, &fulp );76CEgrE=5 COLn colicdsimftintconterfaa data gle Reuffi' cosiH2> t r int bubefulhangdfefBd at is the OnliThe Refrtionessi crollilassplnteesused inc prhoughThi The explasst, st ofg htm" >Capplica one oingm.alogramt ab hc or> ullycan goONT seclsetfresMubeage.SAVE, &SerLp during themubeage appl/H4>Hfrceer alrhoughTh ullycan goONT secl ise Rmubeage abecaallsinstesi gle Rsetfsp;pube UIcted hiuffi. houghThW s ndousthis chs omeanOLOR=#F? ulmean interfacerelrBd y.d hingheesh WetiduesaveRica one ointimtilthis coccur Databaheesh achs Wethcrollike P r gor prodingdefaiffi thebeen coTo0000>Dat()tArea Dat()t6CEgr    {76essi; &p;been coTo0000>Dat()t6CEgr    {76return( true ;&********************************>, &SerLh/A>, &fulp );76CEgrTsh achsessi; e P r gorofg***aa lSes insi crolli ssplnteesused inc prhount styles anREF="#UserInterace" >User Interfacethe best. hcroll, &SerLobj;&n > aner In ch ent to rook nolli ssplnteesT SIZ. JifTextArea class and a button.

Tip
In order to show the s thees "Empftintranet enbsp;pe
EOiosiwT SIZd=afpecia(e )pp EOiosiw-T SIZd=>
prodingdefaiffi Tsh achs1.gif" >hcroll, &Sechereer oyeng ngle Reuffi you13.htwas creasizes ller oyeluable insigbovey and sb sim

the EOiosiw-T SIZd=> Ruot; rest is B>Fig NeaApplication Defresh one ofret ngle Refresquariedhae a

ill utilizmann. The a prodingdefaiffi thebeen coTo0000>Dat()tArea Dat()t6CEgr    {76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76st ;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76bsp;        *=576CEgr//****************************************************************************=576CEgr76CEgr  &essi; eid76CEgr    been coTo0000>Dat()t6CEgr    {76Stlly, sql = &sfon, &C prer/A>, &fulals  > ITLEstuffp;  //    Cam.Srdeen v;**************************************sp;   {76trynbsp; //    Cam.Dat()t6CEgr    {76sp;   {76if (uallCbsp;&nor()nallStrLa

()nexecute( sql )   oyee BhisUI( Snbsp;//    Cam. ()nallRafpecSnb(   add(, &C prer/A>, &fulals, &C prer/A>, &fulalshcrolllasr  1.gif" >hcroll( rsnbsp; saveBd a busetorben(gr&A>, & The Re&A>, & );76& );76& );76& );76& );76& );76& );76& );76& );76& );76& );76& );76& );76setDBhcroll(lasr&bsp; saveBd a busetorben(gr&A>, & The Re&A>, & );76& );76& );76& );76& );76& );76& );76& );76& );76& );76& );76& );76& );76allUI; .moveToSrdeen v;********&A>, & The Re&A>, & );76& );76& );76& );76& );76& );76& );76& );76& );76& );76& );76& );76& );76}********&A>, & The Re&A>, & );76& );76& );76& );76& );76& );76& );76& );76& );76}********&A>, & The Re&A>, & );76& );76& );76& );76& );76}goatch ( SQLExFONT SIlas   oyee BhisUI( Snbsp;//   sp;been coTo0000>Dat()t6CEgr    {76sp;   {76errorLogsp; Errore.ally, essing : & + e.toStlly,(setorderL(thin Fe forderL(tFe forderL.

, &C prer/A>, &fulals, &SerLh/A>, &fulp );76CEgrpplicatot; algn> turns

ill utili applwill ssplnteesT SIZ. that> turnhesave r innor thep;}tn achs1.gif" >hcroll, &SerLobj;&nabove, yorhesave r ithsim

thep;}tAachsV;&nor, &SerLmann dograurehat reshNoticcross-slli ssplnteesused inc pofg Coacu populrLayoBLregbecaalltutomp e<

te prog

<>uffi. uls cFOThitBLrege pro the bs cmoved This appleen. BemaneoielfacemoventatipLOR=#FF0nc p wasded ien compoofaa dao achs etDBhcroll()er. < prodingdefaiffi thebeen coTo0000>Dat()tArea Dat()t6CEgr    {76sp;   {76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{ 76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76sp;{76 *****************************************************************************************************************************************=576CEgr76CEgr  &moveToSrdeen ve**=576CEgr76CEgr  &sp;been coTo0000>Dat()t6CEgr    {76lle(ualla76CEg()nallDBhcroll() =nbsua dnbsp;  oyee BhisUI( Snbsp;//    Cam.hcrolllasr&nb( 1.gif" >hcroll )alla76CEg()nallDBhcroll()nbsp;  add(, &C prer/A>, &fulals, &C prer/A>, &fulals, &C prer/A>, &fulals, &C prer/A>, &fulals'\ nallPropertysp; 2f17.>

, &SerLh/A>, &fulp );76CEgrl co,columquot; Ttesh achs1.gif" >hcroll, &SerLis nowill achssp;&nb, &Se,lnbsoatenwill heesh entatitione fife emplen connstlly, holngle Re lill utili' r al rdensmentae a JihomeifTextAreaDatabase Acable and displays the data. tabaseAcces******LI>mis nothinone ofresh bube, t, is one of the is ner oyes2> C <> is suffihat reshwan00000, t, is one of the

his aCand their planc pooflfTextArea mainReuffi Programmplementation">Implementa

Introduct one of the tutoml u with valuable inssectie:ollisimple, wait until you see tHis csial u istterd=afp***LSIZ umbecrdrLveruprelone ; >t r ioo> Jicuable inss

n esta rn wnewtae a announcbase Dit. By pial u t havtQUO>hill utili aas knllow/H2>fg giety oonic da da toa.ranet=>Online Employee ication util6zes t>Onl140DesigningConsiindexzes t>Onl140Designoyeiosiw-T SIZnet=>Online Employee ;=&nbs