Home >Documents >Tapestry WebTech

Tapestry WebTech

Date post:10-Apr-2018
Category:
View:220 times
Download:0 times
Share this document with a friend
Transcript:
  • 8/8/2019 Tapestry WebTech

    1/75

    Tapestry: Java WebComponents

    Howard M. Lewis [email protected]

  • 8/8/2019 Tapestry WebTech

    2/75

    What If

    you could build a web applicationwithout even thinking about URLs? you could use HTML from your HTMLdevelopers as-is? your web application would localize

    itself (just add translations)?

  • 8/8/2019 Tapestry WebTech

    3/75

    What If

    your development team could work together easily ? you could really reuse code ? extending your application meantadding methods, not creating entire

    servlets?

  • 8/8/2019 Tapestry WebTech

    4/75

    What If

    this technology existed now , wastested , documented, proven andready to go ?

    Tapestry: Java WebComponentsTapestry: Java WebComponents

  • 8/8/2019 Tapestry WebTech

    5/75

    Concept

    Tapestry reconceptualizes webapplication development in

    terms of Java objects, methodsand properties

  • 8/8/2019 Tapestry WebTech

    6/75

    Concept

    Removes URLs, query parameters,servlets, HttpSession from developerconsiderations

    Application pages cooperate in terms of Java objects and methods, not URLsand query parameters

    Still allows 100% control over HTMLproduction

  • 8/8/2019 Tapestry WebTech

    7/75

    Concept

    Build complex apps from simple,reusable components"Bake in" best practices

    Error recovery, reportingLocalization / InternationalizationPersonalizationClustering for fail over / scalabilityBrowser-safe HTML

  • 8/8/2019 Tapestry WebTech

    8/75

    Concept

    Reduce amount of Java codingImprove robustness of applicationsSupport team developmentSimplify interaction between HTMLproducers and Java developers

    Alternative to JSPs; more dynamic, nocode generation

  • 8/8/2019 Tapestry WebTech

    9/75

    Concept

    Truly separate HTML and Java codeNo Java code in HTML template -- everNormal, static HTML with someelements marked as "dynamic"Tapestry components provide dynamicbehaviorStill looks like normal HTML, no specialtags

  • 8/8/2019 Tapestry WebTech

    10/75

    Concept

    Empower Java DevelopersWrite less codeWrite interesting code

    All code written in IDEProvide standardized approach to commonproblems

    Break "tyranny of the URL"Develop in terms of objects and properties, notURLs and query parameters

  • 8/8/2019 Tapestry WebTech

    11/75

    Concept

  • 8/8/2019 Tapestry WebTech

    12/75

    Concept

    Framework links response generation(including generating URLs for links andforms) to dispatch logic

    Developers provide pointer toapplication-specific code, executingwhen link clicked or form submitted

    Developer decides what and when ,framework provides how

  • 8/8/2019 Tapestry WebTech

    13/75

    What is a Component?

    GeneralEvery framework has own definition of "component"

    Has to interact with application, othercomponents"Black-box"; shouldn't need to knowimplementation, just the interface

  • 8/8/2019 Tapestry WebTech

    14/75

    What is a Component?

    SwingResponsible for drawing in 2d spaceProperties configured by application (pushmodel)User interaction:

    Event queue -> component Application as event notification listener

  • 8/8/2019 Tapestry WebTech

    15/75

    What is a Component?

    TapestryRenders a portion of (1 dimensional) HTMLstream

    Has parameters that are "bound" toapplication properties (pull model)User interaction:

    Servlet -> framework -> component Application as delegate to component

  • 8/8/2019 Tapestry WebTech

    16/75

    What is a Component?

  • 8/8/2019 Tapestry WebTech

    17/75

    Demo

  • 8/8/2019 Tapestry WebTech

    18/75

    History

    Open Source, LGPLStarted January 2000Moved to SourceForge.net, July 2000

    1.0 Release, May 2001Java Report Article, September 2001OnJava Article, November 20012.0 Release, April 2002> 25000 Downloads from SourceForge

  • 8/8/2019 Tapestry WebTech

    19/75

    Problems and Solutions

  • 8/8/2019 Tapestry WebTech

    20/75

  • 8/8/2019 Tapestry WebTech

    21/75

    Solution: Tapestry

    Minimal changes to HTML templates Addition of jwcid attribute Adds tags in some cases

    HTML still previews properlyHTML Producers and Java Developers

    can work without interfering with eachother

  • 8/8/2019 Tapestry WebTech

    22/75

    Problem: ComplexityRequests are linked to pages (Sun Model 2)

    Servlet (or Struts action) receives requestUpdates "business model"Invokes JSP to render responsePage-oriented dispatch model

    ComponentsBehavior of component defined by component

    Component wants to handle incoming requestComponent needs to know which page to renderresponse

  • 8/8/2019 Tapestry WebTech

    23/75

    Problem: Complexity"Components" require special addressingPage dispatch logic

    Additional query parameters to identify component Ad-hoc code to "find" component, invoke methodsSimilar code in each servlet or Action that includescomponent

    Servlet / Action for componentReceives request, finds component in standardizedwayNeeds to be configured with page to renderresponseJSP may require special setup, known to servlet

  • 8/8/2019 Tapestry WebTech

    24/75

    Problem: Complexity

    Feature creep -- applications grow moreand more complexMany pages have similar functionality

    Navigation barsSearch fieldsLook and Feel

    Looks the same, acts the same ==component

  • 8/8/2019 Tapestry WebTech

    25/75

    Solution: TapestryEverything is a componentFramework handles component addressing

    Builds and interprets URLsFinds right component on incoming request,invokes component codeComplexity encapsulated by framework

    Manages feature creepNo upper limit: Components per page or nesting level

    Leverages component object model -- just plainworks

  • 8/8/2019 Tapestry WebTech

    26/75

    Problem: ScalabilityJ2EE Approach: Clustering multiple serversData stored in HttpSession copied to otherservers in clusterLots of pitfalls

    Forgetting to store valuesForgetting to delete unneeded values (bloat)References getting copied (can duplicate objects)EJB references must be converted to EJB Handles

    Creating HttpSession too early inefficient, toolate is too late (lots of coding headaches)

  • 8/8/2019 Tapestry WebTech

    27/75

    Solution: TapestrySingle object, "engine", stores all server-sidestate

    Automatically stored into HttpSession at end

    of request cycleHttpSession created only when neededRun with or without Cookies equally well

    State appears as JavaBeans propertiesNo code to move values in or out of HttpSession

  • 8/8/2019 Tapestry WebTech

    28/75

    Problem: Team Development /Integration

    Lots of developers, each contributing "theirpiece"Interface a combination of:

    Servlets or Struts ActionsURL query parametersJava code inside JSPJSP tags

    Different developers, different "interfaces"Lack of standards for behavior, naming,errors

  • 8/8/2019 Tapestry WebTech

    29/75

    Problem: Team Development /Integration

    Code that builds URL, interprets URL caneasily get out of syncHard to get a "component" to work inside a"page"

    Setup code inside Struts ActionMore code inside JSPJSP includes

    Things have to be named "just so"Evolving a component requires changes toeverywhere component is used

  • 8/8/2019 Tapestry WebTech

    30/75

    Solution: Tapestry

    Everything is a componentComponents have named parametersthat are "bound" to page propertiesComponents can read or set propertiesof page via parameters

    Consistent approach, easy to documentEclipse Plugin for Tapestry

  • 8/8/2019 Tapestry WebTech

    31/75

    Problem: Internationalization

    Applications need to be localizedHodge podge of techniquesStruts everywhere

    Single message fileObscures HTML for HTML producersComplex linking between translated pages

    More pages == more complexity == morebugsLots of code everywhere to "find" righttranslation

  • 8/8/2019 Tapestry WebTech

    32/75

    Solution: TapestryEach page, or component may havelocalized templatesTapestry automatically selects correct

    templateCan use message files insteadCan mix and matchCan localize assets (images,stylesheets, etc.) as well

  • 8/8/2019 Tapestry WebTech

    33/75

  • 8/8/2019 Tapestry WebTech

    34/75

    Problem: DebuggingJSPs convert to ugly, unreadable codeHard to get IDE to "recognize" Java codefrom JSPsErrors in JSPs result in blank page or crypticerror messageThrown exceptions not reported well

    Usually, only outermost exception displayed, wheninnermost exception most helpfulWith Struts, exception often "lost" and notreported

  • 8/8/2019 Tapestry WebTech

    35/75

    Solution: Tapestry

    No code generation! Ever!Multiple layers of exception handlingand reportingExceptions get very complete report

  • 8/8/2019 Tapestry WebTech

    36/75

    Solution: TapestryException report:

    All exceptions (outermost to innermost)Properties of exceptions

    Stack trace of innermost exceptionComplete rundown of all objects:HttpServletRequest

    HttpSessionServletContextJVM System Properties

  • 8/8/2019 Tapestry WebTech

    37/75

    Solution: Tapestry

    Example:Bad XML in Tapestry specification fileResult: Exception report includes

    SAXException with exact position of errorSavings: Didn't have t

of 75

Embed Size (px)
Recommended