Google Web Toolkit

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

GoogleWebToolkitTakingthepainoutofAjaxEdBurnetteThePragmaticBookshelfRaleigh,NorthCarolinaDallas,TexasPreparedexclusivelyforTomaszPankowskiManyofthedesignationsusedbymanufacturersandsellerstodistin-guishtheirproductsareclaimedastrademarks.Wherethosedesignationsappearinthisbook,andThePragmaticProgrammers,LLCwasawareofatrademarkclaim,thedesignationshavebeenprintedininitialcapitallettersorinallcapitals.ThePragmaticStarterKit,ThePragmaticPro-grammer,PragmaticProgramming,PragmaticBookshelfandthelinkinggdevicearetrademarksofThePragmaticProgrammers,LLC.UsefulFridayLinks•Sourcecodefromthisbookandotherresources.•FreeupdatestothisPDF•Errataandsuggestions.Toreportanerratumonapage,clickthelinkinthefooter.Everyprecautionwastakeninthepreparationofthisbook.However,thepublisherassumesnoresponsibilityforerrorsoromissions,orfordam-agesthatmayresultfromtheuseofinformation(includingprogramlist-ings)containedherein.Toseewhatwe’reupto,pleasevisitusat©2006ThePragmaticProgrammersLLC.Allrightsreserved.ThisPDFpublicationisintendedforthepersonaluseoftheindividualwhosenameappearsatthebottomofeachpage.Thispublicationmaynotbedisseminatedtoothersbyanymeanswithoutthepriorconsentofthepublisher.Inparticular,thepublicationmustnotbemadeavailableontheInternet(viaawebserver,filesharingnetwork,oranyothermeans).ProducedintheUnitedStatesofAmerica.BookshelfPragmaticLovinglycreatedbygerbil#52on2006-9-11PreparedexclusivelyforTomaszPankowskiFridaysContents1Introduction11.1LifebeforeGWT......................11.2WhatGWTdoesforyou.................31.3Aboutthisbook......................32GettingStarted52.1Supportedplatforms...................52.2Installing.........................52.3Createscaffolding....................72.4Runninganddebugging.................83Hostedvs.WebMode113.1Hostedmode.......................113.2Webmode.........................133.3Obfuscation........................153.4Deployment........................164UserInterface174.1TyingintoHTML.....................174.2Entrypoint........................194.3Events...........................204.4Widgets..........................214.5Panels...........................285RemoteProcedureCalls325.1Wheredoesyourcodelive?...............325.2Callingremotecode...................335.3Whyanewprotocol?...................335.4GWTRPCbasics.....................34PreparedexclusivelyforTomaszPankowskiFridaysCONTENTSCONTENTSiv5.5Serialization........................406HistoryandBookmarks436.1TheHistoryToken....................436.2HistoryListener......................446.3HowitWorks.......................446.4Example..........................457JavaScriptNativeInterface487.1DeclaringaNativeMethod...............487.2HowitWorks.......................497.3CallingJSNIfromJava.................497.4CallingJavafromJSNI.................507.5Example..........................528JavaEmulation558.1Languagesubset.....................558.2Librarysubset......................588.3Supportedpackages...................598.4RegularExpressions...................61ReporterratumPreparedexclusivelyforTomaszPankowskiFridaysChapter1IntroductionTheGoogleWebToolkit(GWT)wasunveiledtoanunsuspectingpubliconMay18th,2006attheannualJavaOneconferenceinSanFrancisco.ThepremisebehindGWTissimple:makeAjax1develop-menteasierbyhidingbrowserincompatibilitiesfromtheprogram-merandallowingthedevelopertoworkinafamiliarJavadevelop-mentenvironment.Theannouncementwasoneofthehighlightsoftheconferenceandinterestcontinuestogrow.DevelopershaveusedGWTtechnologyineverythingfromgamestomortgagecalculators.ThegwtPoweredcommunitysitelistsover100examples,articles,widgets,andotherresources.WhyhastheGoogleWebToolkitbecomesuchahottopic?Ifyou’veeverwrittenanon-trivialAjaxapplicationbefore,thenI’msureyoucansympathizewiththeneedtomaketheprocesseasier.Ifnot,thenalittlebackgroundisinorder.1.1LifebeforeGWTDynamicwebapplicationsaretypicallywritteninseveraldiffer-entlanguagesacrosstwoormoretiers.Ontheclientside(thepartrunninginthebrowser),youhaveHTMLmarkupofcourse,1ThetermAjaxwasfamouslycoinedinFebruary2005byJesseJamesGarrett.OriginallyitwasanacronymforAsynchronousJavascriptAndXml.Thetechnol-ogyhasactuallybeenaroundforafewyears—forexampleitwasusedinOutlookWebAccessin2000—butdidn’tgetmuchattentionuntilGooglepopularizeditwithapplicationssuchasGMailandGoogleMaps.PreparedexclusivelyforTomaszPankowskiFridaysCHAPTER1.INTRODUCTIONLIFEBEFOREGWT2plusyouhavesomelogicwritteninJavaScripttoperformtaskslikeclient-sidevalidationandmanipulationoftheHTMLdocumentobjectmodel(DOM).Unfortunately,slightdifferencesintheJavaScriptlanguagebetweenJavaScriptisared-headedstep-childofalanguagethatfirstappearedintheNetscapebrowserin1995asawaytoscriptJavaapplets.ItwasadoptedbyMicrosoftinthefollowingyear,becomingthede-factostandardforscriptinginsidethebrowser.DespitehavingJavainitsname,itbearslittleresemblancetothatlanguage.TheclosestthingtoJavaScriptwouldbe...wellactuallythere’snothingquitelikeJavaScript.Somewouldcountthatasagoodthing.browsers,alongwithmajordifferenc

1 / 68
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功