element.ThereexistsatoolforgeneratingthisXMLdataautomatically.Thetoolreadsdatabasemetadataofaspecifieddatabaseandconstructsaconfigurationfile,asshowninListing1.TheController:
Parsing,Dispatching,andExecutingEvents
Aspointedoutabove,youdonotneedtoprovideanyController-relatedcodewhentheControllerisatrueinfrastructuralcomponent.However,it'susefulifyouhaveanideaofwhat'sgoingoninsidetheController.Thefollowinglinesprovidethatinformation.
TheControllerincludesseveralcomponents:
ControllerServlet:
thisservletisthesinglepointofentryforallincomingHTTPrequestsfromclients.
EventEngine:
anassistanttotheControllerServlet,itfocusesonfilteringHTTPrequestsforWebEventsandinstantiatesthem.
WebEventObjects:
allObjectsderivedfromtheabstractsuper-classWebEventhavetheabilitytoinitializethemselvesbyreadingagivenHTTPrequest.Theseeventsgetexecuted,eitherdirectlybytheControllerorbytheView.
Thefollowingdescriptionoftheexecutionofatypicaluseractionshouldgiveyouabetterpictureofwhatthecontrollerdoesandhowitinteractswiththeothercomponents:
1.Userpressesthebutton"deleterow"onhis/herDbFormsapplication.
2.ClientbrowsersubmitsdataviaHTTP-POSTtotheController-servlet.
3.TheControllerServletdelegatestheincomingrequesttotheEventEngine,whichdeterminesthemainevent(theuserexplicitlytriggeredtheeventbyclickingabutton).However,theremayoccurimplicitevents,too--i.e.,automaticupdatingofallchangedinputfieldsofalldatarows.
4.TheEventEnginecomponentparsesthatrequestanddeterminesthekindofactiontheuserwantstobeexecuted.
5.ItthencreatestheappropriateWebEvent(inourcase,aDeleteEvent)anddelegatestherequestObjecttothisnewly-createdWebEvent,whichfinalizesitsowninitialization.Afterthat,theEventEnginereturnstherecently-createdand-initializedeventbacktotheControllerServlet.
6.TheControllerServlettellstheeventtoexecuteitsbuilt-inoperation,ifitisaDatabaseEvent.Otherevents(NavigationEvent,etc.)aredelegatedtotheappropriateViewcomponent.
7.TheControllerServletinvokesEventEngineagaintocheckifthereareadditional(implicit)eventstobeexecuted.Ifso,theappropriatedWebEventObjectsarecreatedandexecutedinthesamemannerasthemaineventdescribedabove.
8.TheControllerServletdeterminestheViewcomponenttowhichtherequestshouldbeforwarded.Iffound,theControllerServletinvokesthecomponentandforwardstherequest.
9.IftheViewcomponentisaJSPpagecontainingDbFormstags,thosetagswillsearchfornavigationeventstobeexecuted,andwillfinallygeneratetheresponsefortheuser.
10.Theresponseisrenderedbytheuser'sWebbrowser.
TheView:
JSPTemplatesProvidedbytheApplicationDeveloper
TheViewportionofaDbFormsapplicationisgenerallyconstructedusingJSPtechnology.JSPfilesmaycontainstaticHTMLelements,aswellasdynamicelementscontainingJavacode(definitions,statements,expressions).FormoreinformationaboutJSP,pleaseseeSun'sJSPpage.
Withrelease1.1oftheJSPAPI,apowerfulfacilitycalledJSPtaglibrarieswasadded.Withthesecustomtags,youcanencapsulateevenmostsophisticatedJavacodeintolightweightJSPtags.
DbFormsmakesuseofthegreatpotentialofJSPtaglibraries.Itcontainsanextensivecustomtagslibraryforrenderingandmanipulatingdatabasedata.
TheStructureofaDbFormsView
Figure1givesaconceptualoverviewofthemaincomponentsofatypicalDbFormsview.
TheBasicConceptsofForms
EachDbForms-viewJSPmayhaveoneormoreroottagsofthetypeform.Everyformtaghastocontainexactlyoneheadertag,exactlyonebodytag,andexactlyonefootertag,inexactlythatorder.
Eachofthosetagsmaycontainsub-elementslikedatafields,inputfields,actionbuttons,and--ofcourse--plainHTMLtextandJSPcode.
headerandfootertagsarecommonlyusedfortitlesofpages,labellingtables,placingactionandnavigationbuttons,inputfieldstoenternewdata,etc.headerandfootertagsgetevaluatedonlyonce.
Thebodytagisusedforshowingdatarowscomingfromthedatabase,andforprovidingtheuserwiththefunctionalitytoeditthatdata.Howmanytimesthebodytaganditssub-elementsgetrendereddependsonthevalueofthemaxRowsattributeoftheformelement(andofcourse,onthenumberofdatasetsactuallyfetchedfromthedatabase).
maxRows=n--bodygetsexecutedntimesatmaximum(withninN)
maxRows="*"--bodygetsexecutedforeveryrowinthetable("endless"form)
NestedForms
Everyformmaycontainoneormorenestedsub-formsinsideitsbodyelement.
The"orders"formisnestedwithinthebodyelementofthe"customer"form,asshowninFigure2.Theuserwillseeonecustomerperpage(becausemaxRowsissetto"1")andalltheorders(becausemaxRows="*")thecustomerhastaken.Theusermaynavigatethroughthelistofcustomersbyclickingthenavigationbuttons.
OK,Let'sSeeSomeCode!
Asstatedbefore,JSPviewsaretheonlypartsofaDbFormsapplicationadeveloperusuallyneedstoputhis/herhandson.DbFormsprovidesanextensivecustomtaglibrarywhichmakesthisaneasytask,sothatitcanbeperformedevenbynon-programmers.
Aswewillseelater,muchofthiscodecanbegeneratedautomaticallybytoolsincludedinDbForms.However,itisusefultounderstandthebasicsofDbFormsviews,evenifmuchoftheworkcanbedoneautomatically.
ThefollowingtwosectionswillshowasimpleandamoreadvancedexampleofaDbFormsview.BothexamplescanbethoughtasbeingpartsofalittleCRMapplicationofa(virtual)agency.
ASimpleExample
Description:
ThisJSPview(service.jsp)enablestheuser(s)toadministertheservicestheagencyprovidestoitscustomers.Theuser(anemployeeoftheagencyorcallcenteragent)shouldgetalistofalltheexistingservices,alongwithtextfieldsandbuttonstoupdateanddeletedata.Finally,anemptyinputmaskforinsertingnewservicesisneeded.
WehavesetmaxRowsto"*"whichhastheeffectthatallrowswillbeshownatonce.Ifthereexisthundredsofservices,wewouldliketosetmaxRowsto"10,""20,"oranotherlimitednumber,andwewouldinstantiatenavigationbuttonsforscrollingbetweenthepages.Wewillusethatpatternlater.
Theerrorstagshowsalistoferrors,ifanyoccurred(i.e.duplicatekeyerror,etc.).
TheupdateButtonanddeleteButtontagsareplacedinthebodyandthereforerenderedforeachrow.
AnExampleofNestedForms
Thefollowingpage(customer_order.jsp)givesyouthefunctionalitytomanagetheincomingordersofacustomer.Youareabletoeditbothordersofacustomerandthecustomerdataitself.Furthermore,youdonotneedtostrugglewithplainserviceIDs,butwillbeabletoconvenientlyselecttheservicesfromaselectboxbyname.
Withthispage,wehavedemonstratedanothercoupleofm
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
-
英文文献
科技类
原文及翻译
65
英文
文献
科技
原文
翻译
冰豆网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。