A Framework for Enterprise Java

Total Page:16

File Type:pdf, Size:1020Kb

A Framework for Enterprise Java Seam - Contextual Components A Framework for Enterprise Java 2.1.2 by Gavin King, Pete Muir, Norman Richards, Shane Bryzak, Michael Yuan, Mike Youngstrom, Christian Bauer, Jay Balunas, Dan Allen, Max Rydahl Andersen, Emmanuel Bernard, Nicklas Karlsson, Daniel Roth, Matt Drees, Jacob Orshalick, and Marek Novotny edited by Samson Kittoli and thanks to James Cobb (Graphic Design), Cheyenne Weaver (Graphic Design), Mark Newton, Steve Ebersole, Michael Courcy (French Translation), Nicola Benaglia (Italian Translation), Stefano Travelli (Italian Translation), Francesco Milesi (Italian Translation), and Japan JBoss User Group (Japanese Translation) Introduction to JBoss Seam ............................................................................................ xvii 1. Contribute to Seam ............................................................................................. xxi 1. Seam Tutorial .............................................................................................................. 1 1.1. Using the Seam examples .................................................................................. 1 1.1.1. Running the examples on JBoss AS ......................................................... 1 1.1.2. Running the examples on Tomcat ............................................................. 1 1.1.3. Running the example tests ....................................................................... 2 1.2. Your first Seam application: the registration example ............................................ 2 1.2.1. Understanding the code ........................................................................... 3 1.2.2. How it works .......................................................................................... 14 1.3. Clickable lists in Seam: the messages example .................................................. 15 1.3.1. Understanding the code .......................................................................... 15 1.3.2. How it works .......................................................................................... 21 1.4. Seam and jBPM: the todo list example ............................................................... 21 1.4.1. Understanding the code .......................................................................... 22 1.4.2. How it works .......................................................................................... 29 1.5. Seam pageflow: the numberguess example ........................................................ 30 1.5.1. Understanding the code .......................................................................... 31 1.5.2. How it works .......................................................................................... 39 1.6. A complete Seam application: the Hotel Booking example ................................... 40 1.6.1. Introduction ............................................................................................ 40 1.6.2. Overview of the booking example ............................................................ 42 1.6.3. Understanding Seam conversations ......................................................... 42 1.6.4. The Seam Debug Page .......................................................................... 51 1.7. Nested conversations: extending the Hotel Booking example ............................... 52 1.7.1. Introduction ............................................................................................ 52 1.7.2. Understanding Nested Conversations ...................................................... 54 1.8. A complete application featuring Seam and jBPM: the DVD Store example ........... 60 1.9. Bookmarkable URLs with the Blog example ........................................................ 62 1.9.1. Using "pull"-style MVC ............................................................................ 63 1.9.2. Bookmarkable search results page .......................................................... 65 1.9.3. Using "push"-style MVC in a RESTful application ..................................... 68 2. Getting started with Seam, using seam-gen .............................................................. 73 2.1. Before you start ................................................................................................ 73 2.2. Setting up a new project ................................................................................... 74 2.3. Creating a new action ....................................................................................... 77 2.4. Creating a form with an action ........................................................................... 78 2.5. Generating an application from an existing database ........................................... 79 2.6. Generating an application from existing JPA/EJB3 entities ................................... 80 2.7. Deploying the application as an EAR ................................................................. 80 2.8. Seam and incremental hot deployment ............................................................... 80 2.9. Using Seam with JBoss 4.0 ............................................................................... 81 2.9.1. Install JBoss 4.0 .................................................................................... 81 2.9.2. Install the JSF 1.2 RI ............................................................................. 82 iii Seam - Contextual Components 3. Getting started with Seam, using JBoss Tools .......................................................... 83 3.1. Before you start ................................................................................................ 83 3.2. Setting up a new Seam project .......................................................................... 83 3.3. Creating a new action ....................................................................................... 99 3.4. Creating a form with an action ......................................................................... 101 3.5. Generating an application from an existing database ......................................... 102 3.6. Seam and incremental hot deployment with JBoss Tools ................................... 104 4. The contextual component model ........................................................................... 105 4.1. Seam contexts ................................................................................................ 105 4.1.1. Stateless context .................................................................................. 105 4.1.2. Event context ....................................................................................... 106 4.1.3. Page context ........................................................................................ 106 4.1.4. Conversation context ............................................................................ 106 4.1.5. Session context .................................................................................... 107 4.1.6. Business process context ..................................................................... 107 4.1.7. Application context ............................................................................... 107 4.1.8. Context variables .................................................................................. 107 4.1.9. Context search priority .......................................................................... 108 4.1.10. Concurrency model ............................................................................. 108 4.2. Seam components .......................................................................................... 109 4.2.1. Stateless session beans ....................................................................... 109 4.2.2. Stateful session beans .......................................................................... 110 4.2.3. Entity beans ......................................................................................... 110 4.2.4. JavaBeans ........................................................................................... 111 4.2.5. Message-driven beans .......................................................................... 111 4.2.6. Interception .......................................................................................... 111 4.2.7. Component names ............................................................................... 112 4.2.8. Defining the component scope .............................................................. 114 4.2.9. Components with multiple roles ............................................................. 114 4.2.10. Built-in components ............................................................................ 115 4.3. Bijection .......................................................................................................... 115 4.4. Lifecycle methods ........................................................................................... 118 4.5. Conditional installation ..................................................................................... 119 4.6. Logging .......................................................................................................... 120 4.7. The Mutable interface and @ReadOnly ............................................................. 121 4.8. Factory and manager components ................................................................... 124 5. Configuring Seam components ..............................................................................
Recommended publications
  • Java (Programming Langua a (Programming Language)
    Java (programming language) From Wikipedia, the free encyclopedialopedia "Java language" redirects here. For the natural language from the Indonesian island of Java, see Javanese language. Not to be confused with JavaScript. Java multi-paradigm: object-oriented, structured, imperative, Paradigm(s) functional, generic, reflective, concurrent James Gosling and Designed by Sun Microsystems Developer Oracle Corporation Appeared in 1995[1] Java Standard Edition 8 Update Stable release 5 (1.8.0_5) / April 15, 2014; 2 months ago Static, strong, safe, nominative, Typing discipline manifest Major OpenJDK, many others implementations Dialects Generic Java, Pizza Ada 83, C++, C#,[2] Eiffel,[3] Generic Java, Mesa,[4] Modula- Influenced by 3,[5] Oberon,[6] Objective-C,[7] UCSD Pascal,[8][9] Smalltalk Ada 2005, BeanShell, C#, Clojure, D, ECMAScript, Influenced Groovy, J#, JavaScript, Kotlin, PHP, Python, Scala, Seed7, Vala Implementation C and C++ language OS Cross-platform (multi-platform) GNU General Public License, License Java CommuniCommunity Process Filename .java , .class, .jar extension(s) Website For Java Developers Java Programming at Wikibooks Java is a computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few impimplementation dependencies as possible.ble. It is intended to let application developers "write once, run ananywhere" (WORA), meaning that code that runs on one platform does not need to be recompiled to rurun on another. Java applications ns are typically compiled to bytecode (class file) that can run on anany Java virtual machine (JVM)) regardless of computer architecture. Java is, as of 2014, one of tthe most popular programming ng languages in use, particularly for client-server web applications, witwith a reported 9 million developers.[10][11] Java was originallyy developed by James Gosling at Sun Microsystems (which has since merged into Oracle Corporation) and released in 1995 as a core component of Sun Microsystems'Micros Java platform.
    [Show full text]
  • Not-Dead-Yet--Java-On-Desktop.Pdf
    NOT DEAD YET Java on Desktop About me… Gerrit Grunwald 2012… The desktop is dead… …the future of applications… …is the Web ! 8 years later… My application folder… My applications folder (future) My applications folder (reality) ??? Seems desktop is not dead ! But what about Java ? Available Toolkits AWT Abstract Window Toolkit Abstract Window Toolkit Since 1995 Cross Platform Platform dependent Bound to native controls Interface to native controls SWT Standard Window Toolkit Standard Window Toolkit Based on IBM Smalltalk from 1993 Cross Platform Platform dependent Wrapper around native controls Java Swing Successor to AWT Java Swing Since Java 1.2 (1998) Cross Platform Platform independent Introduced Look and Feels Emulates the appearance of native controls Java FX Script Intended successor to Swing Java FX Script Since Java 1.6 (2008) Cross Platform Platform independent No Java Syntax Declarative way to describe UI's (based on F3 from Chris Oliver) Java FX Successor to Swing Java FX Since Java 7 (2011) Cross Platform Platform independent Port from JavaFX Script to Java Not part of the Java SE distribution since Java 11 Most of these are still in use… Is Java FX dead ? Is Java FX dead ? Open Sourced as OpenJFX (openjfx.io) Driven by the community Can run on mobile using Gluon technology (gluonhq.com) Can run on web using JPro technology (jpro.one) Actively developed and is getting new features too Where does Java on Desktop suck ? Lack of 3rd party controls Swing had great support over years, JavaFX lacks behind Missing features… e.g.
    [Show full text]
  • Scala Tutorial
    Scala Tutorial SCALA TUTORIAL Simply Easy Learning by tutorialspoint.com tutorialspoint.com i ABOUT THE TUTORIAL Scala Tutorial Scala is a modern multi-paradigm programming language designed to express common programming patterns in a concise, elegant, and type-safe way. Scala has been created by Martin Odersky and he released the first version in 2003. Scala smoothly integrates features of object-oriented and functional languages. This tutorial gives a great understanding on Scala. Audience This tutorial has been prepared for the beginners to help them understand programming Language Scala in simple and easy steps. After completing this tutorial, you will find yourself at a moderate level of expertise in using Scala from where you can take yourself to next levels. Prerequisites Scala Programming is based on Java, so if you are aware of Java syntax, then it's pretty easy to learn Scala. Further if you do not have expertise in Java but you know any other programming language like C, C++ or Python, then it will also help in grasping Scala concepts very quickly. Copyright & Disclaimer Notice All the content and graphics on this tutorial are the property of tutorialspoint.com. Any content from tutorialspoint.com or this tutorial may not be redistributed or reproduced in any way, shape, or form without the written permission of tutorialspoint.com. Failure to do so is a violation of copyright laws. This tutorial may contain inaccuracies or errors and tutorialspoint provides no guarantee regarding the accuracy of the site or its contents including this tutorial. If you discover that the tutorialspoint.com site or this tutorial content contains some errors, please contact us at [email protected] TUTORIALS POINT Simply Easy Learning Table of Content Scala Tutorial ..........................................................................
    [Show full text]
  • The Dzone Guide to Volume Ii
    THE D ZONE GUIDE TO MODERN JAVA VOLUME II BROUGHT TO YOU IN PARTNERSHIP WITH DZONE.COM/GUIDES DZONE’S 2016 GUIDE TO MODERN JAVA Dear Reader, TABLE OF CONTENTS 3 EXECUTIVE SUMMARY Why isn’t Java dead after more than two decades? A few guesses: Java is (still) uniquely portable, readable to 4 KEY RESEARCH FINDINGS fresh eyes, constantly improving its automatic memory management, provides good full-stack support for high- 10 THE JAVA 8 API DESIGN PRINCIPLES load web services, and enjoys a diverse and enthusiastic BY PER MINBORG community, mature toolchain, and vigorous dependency 13 PROJECT JIGSAW IS COMING ecosystem. BY NICOLAI PARLOG Java is growing with us, and we’re growing with Java. Java 18 REACTIVE MICROSERVICES: DRIVING APPLICATION 8 just expanded our programming paradigm horizons (add MODERNIZATION EFFORTS Church and Curry to Kay and Gosling) and we’re still learning BY MARKUS EISELE how to mix functional and object-oriented code. Early next 21 CHECKLIST: 7 HABITS OF SUPER PRODUCTIVE JAVA DEVELOPERS year Java 9 will add a wealth of bigger-picture upgrades. 22 THE ELEMENTS OF MODERN JAVA STYLE But Java remains vibrant for many more reasons than the BY MICHAEL TOFINETTI robustness of the language and the comprehensiveness of the platform. JVM languages keep multiplying (Kotlin went 28 12 FACTORS AND BEYOND IN JAVA GA this year!), Android keeps increasing market share, and BY PIETER HUMPHREY AND MARK HECKLER demand for Java developers (measuring by both new job 31 DIVING DEEPER INTO JAVA DEVELOPMENT posting frequency and average salary) remains high. The key to the modernization of Java is not a laundry-list of JSRs, but 34 INFOGRAPHIC: JAVA'S IMPACT ON THE MODERN WORLD rather the energy of the Java developer community at large.
    [Show full text]
  • Scala for the Impatient
    Scala for the Impatient Copyright © Cay S. Horstmann 2012. All Rights Reserved. The evolution of Java and C++ has slowed down considerably, and programmers who are eager to use more modern language features are looking elsewhere. Scala is an attractive choice; in fact, I think it is by far the most attractive choice for programmers who want to move beyond Java or C++. Scala has a concise syntax that is refreshing after the Java boilerplate. It runs on the Java virtual machine, providing access to a huge set of libraries and tools. It embraces the functional programming style without abandoning object-orientation, giving you an incremental learning path to a new paradigm. The Scala interpreter lets you run quick experiments, which makes learning Scala very enjoyable. And, last but not least, Scala is statically typed, enabling the compiler to find errors, so that you don't waste time finding them later in running programs (or worse, don't find them). I wrote this book for impatient readers who want to start programming with Scala right away. I assume you know Java, C#, or C++, and I won't bore you with explaining variables, loops, or classes. I won't exhaustively list all features of the language, I won't lecture you about the superiority of one paradigm over another, and I won't make you suffer through long and contrived examples. Instead, you will get the information that you need in compact chunks that you can read and review as needed. Scala is a big language, but you can use it effectively without knowing all of its details intimately.
    [Show full text]
  • Programming Groovy.Pdf
    What readers are saying about Programming Groovy More than a tutorial on the Groovy language, Programming Groovy is an excellent resource for learning the advanced concepts of metaob- ject programming, unit testing with mocks, and DSLs. This is a must- have reference for any developer interested in learning to program dynamically. Joe McTee Developer, JEKLsoft Venkat does a fantastic job of presenting many of the advanced fea- tures of Groovy that make it so powerful. He is able to present those ideas in a way that developers will find very easy to internalize. This book will help Groovy developers take their kung fu to the next level. Great work, Venkat! Jeff Brown Member, the Groovy and Grails development teams At this point in my career, I am really tired of reading books that introduce languages. This volume was a pleasant breath of fresh air, however. Not only has Venkat successfully translated his engaging speaking style into a book, he has struck a good balance between introductory material and those aspects of Groovy that are new and exciting. Java developers will quickly grasp the relevant concepts without feeling like they are being insulted. Readers new to the plat- form will also be comfortable with the arc he presents. Brian Sletten Zepheira, LLC You simply won’t find a more comprehensive resource for getting up to speed on Groovy metaprogramming. Jason Rudolph Author, Getting Started with Grails This book is an important step forward in mastering the language. Venkat takes the reader beyond simple keystrokes and syntax into the deep depths of “why?” Groovy brings a subtle sophistication to the Java platform that you didn’t know was missing.
    [Show full text]
  • Advanced-Java.Pdf
    Advanced java i Advanced java Advanced java ii Contents 1 How to create and destroy objects 1 1.1 Introduction......................................................1 1.2 Instance Construction.................................................1 1.2.1 Implicit (Generated) Constructor.......................................1 1.2.2 Constructors without Arguments.......................................1 1.2.3 Constructors with Arguments........................................2 1.2.4 Initialization Blocks.............................................2 1.2.5 Construction guarantee............................................3 1.2.6 Visibility...................................................4 1.2.7 Garbage collection..............................................4 1.2.8 Finalizers...................................................5 1.3 Static initialization..................................................5 1.4 Construction Patterns.................................................5 1.4.1 Singleton...................................................6 1.4.2 Utility/Helper Class.............................................7 1.4.3 Factory....................................................7 1.4.4 Dependency Injection............................................8 1.5 Download the Source Code..............................................9 1.6 What’s next......................................................9 2 Using methods common to all objects 10 2.1 Introduction...................................................... 10 2.2 Methods equals and hashCode...........................................
    [Show full text]
  • Develop a Simple Web Application with Apache Wicket and Apache
    Develop a simple Web application with Apache Wicket and Apache Geronimo Combine Wicket, Geronimo, and Apache Derby to form an open source Java Web development platform Skill Level: Intermediate Robi Sen ([email protected]) Vice President Department 13 LLC 10 Jul 2007 Apache Wicket is an innovative Java™ Web application framework that was introduced a couple of years ago. It helps simplify Web application development by clearly separating the roles of developers and designers. It lets you remove logical code from the view layer, eliminating the need for JavaServer Pages (JSP), providing a simple plain old Java object (POJO)-centric mode of development, and removing much of the need for XML and other configuration file formats. In this tutorial, learn how to set up your system to develop a simple Web application with Wicket, using Apache Geronimo as your application server and Apache Derby as the embedded database. Section 1. Before you start This tutorial is designed for developers who have found Java frameworks, such as Struts, lacking in needed functionality. If you're interested in developing Web applications in a more object-oriented manner, where the view is clearly separated from logic and there's minimal configuration and mapping, then Wicket is for you! This tutorial walks you through the basics of how Wicket works, while using Apache Geronimo to set up a Java Platform, Enterprise Edition (Java EE) server, Web server, and embedded database in just minutes. Combining Wicket with Geronimo lets you develop data-driven, scalable Web applications using software that's all open source. Develop a simple Web application with Apache Wicket and Apache Geronimo © Copyright IBM Corporation 1994, 2008.
    [Show full text]
  • Java Server Face
    Java Server Face From the specification 2.0 JSF sources ● JSF specification 2.0 ● JSF sun tutorials EE6 ● Core Java server face (http://horstmann.com/corejsf/) ● http://jsftutorials.net/ ● JSF Lectures from Pascal URSO (Mcf Nancy) ● JSF Lectures from François Charoy (Mcf Nancy) ● Intro à JSF : [email protected] ● JSF and ICEFaces (?? anonymous) My Source ?? Overview and motivations ● JavaServer Faces (JSF) is a user interface (UI) framework for Java web applications. It is designed to significantly ease the burden of writing and maintaining applications that run on a Java application server and render their UIs back to a target client. JSF provides ease-of-use in the following ways: ● Makes it easy to construct a UI from a set of reusable UI components ● Simplifies migration of application data to and from the UI ● Helps manage UI state across server requests ● Provides a simple model for wiring client-generated events to server-side application code ● Allows custom UI components to be easily built and re-used Solving pratical problems of the web ● Managing UI component state across request ● Supporting encapsulation of the differences in markup across different browsers and clients ● Supporting form processing (multi-page, more than one per page, and so on) ● Providing a strongly typed event model that allows the application to write server- side handlers (independent of HTTP) for client generated events ● Validating request data and providing appropriate error reporting ● Enabling type conversion when migrating markup values (Strings) to and from application data objects (which are often not Strings) ● Handling error and exceptions, and reporting errors in human-readable form back to the application user ● Handling page-to-page navigation in response to UI events and model interactions.
    [Show full text]
  • Icefaces Getting Started Guide V1.7 Iii Prerequisites
    Getting Started Guide Version 1.7 Copyright Copyright 2005-2008. ICEsoft Technologies, Inc. All rights reserved. The content in this guide is protected under copyright law even if it is not distributed with software that includes an end user license agreement. The content of this guide is furnished for informational use only, is subject to change without notice, and should not be construed as a commitment by ICEsoft Technologies, Inc. ICEsoft Technologies, Inc. assumes no responsibility or liability for any errors or inaccuracies that may appear in the informational content contained in this guide. ICEfaces is a registered trademark of ICEsoft Technologies, Inc. Sun, Sun Microsystems, the Sun logo, Solaris and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and in other countries. All other trademarks mentioned herein are the property of their respective owners. ICEsoft Technologies, Inc. Suite 200, 1717 10th Street NW Calgary, Alberta, Canada T2M 4S2 Toll Free: 1-877-263-3822 (USA and Canada) Telephone: 1-403-663-3322 Fax:1-403-663-3320 For additional information, please visit the ICEfaces web site: http://www.icefaces.org ICEfaces v1.7 April 2008 About this Guide The ICEfaces® Getting Started Guide will help you quickly get started building ICEfaces applications. By reading through this guide, you will: • Gain a basic understanding of what ICEfaces is and what it can do for you. • Install ICEfaces and run the sample applications on your local application server. • Work through a basic ICEfaces tutorial that transforms a standard JSF application into a rich web application powered by ICEfaces.
    [Show full text]
  • Ajax, State of The
    AjAjaax,x, ststaattee ooff tthhee aarrtt Tarek Ziadé, Nuxeo [email protected] WWhhoo aamm ii ● I am engineer at Nuxeo ● I work on CPS, the famous ECM Plateform ;) ● I©ve been lately in charge of Ajax stuff in CPS ● I read Ajax related feeds before I go to bed WWhhaatt iiss AAjjaaxx ?? A dutch football club (a good one) A cleanser (really works) AA WWeebb 22..00 tteechchnnoollooggyy Asynchronous Javascript And XML WWhhaatt©©ss WWeebb 22..00 ?? TTiimm OO©©RReeiillllyy©©ss ©©ccoommppaacctt©© ddeeffiinniittiioonn:: Web 2.0 is the network as platform, spanning all connected devices; Web 2.0 applications are those that make the most of the intrinsic advantages of that platform: delivering software as a continually-updated service that gets better the more people use it, consuming and remixing data from multiple sources, including individual users, while providing their own data and services in a form that allows remixing by others, creating network effects through an "architecture of participation," and going beyond the page metaphor of Web 1.0 to deliver rich user experiences. MMaarrkkuuss AAnnggeerrmmeeiieerr©©ss vviieeww ooff WWeebb 22..00:: (courtesy of Markus Angermeier) WWeebb 22..00 AAppppss ✔ del.icio.us ✔ flickr ✔ Voo2do ✔ Digg ✔ Google Mail (Gmail) ✔ Writely ✔ Basecamp ✔ ... AjAjaaxx bbiigg ppiictctuurere 11//22 (courtesy of J. J. Garett) AjAjaaxx bbiigg ppiictctuurere 22//22 (courtesy of J. J. Garett) TThhee LLiistst ooff tthhiinnggss AjAjaaxx rereaallllyy bbririnnggss ✔ Increases interactivity ✔ Save bandwidth ✔ Helps avoiding some interactive
    [Show full text]
  • Third-Party License Acknowledgments
    Symantec Privileged Access Manager Third-Party License Acknowledgments Version 3.3.5 Symantec Privileged Access Manager Third-Party License Acknowledgments Broadcom, the pulse logo, Connecting everything, and Symantec are among the trademarks of Broadcom. Copyright © 2019 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. For more information, please visit www.broadcom.com. Broadcom reserves the right to make changes without further notice to any products or data herein to improve reliability, function, or design. Information furnished by Broadcom is believed to be accurate and reliable. However, Broadcom does not assume any liability arising out of the application or use of this information, nor the application or use of any product or circuit described herein, neither does it convey any license under its patent rights nor the rights of others. 2 Symantec Privileged Access Manager Third-Party License Acknowledgments Contents Activation 1.1.1 ..................................................................................................................................... 7 Adal4j 1.1.2 ............................................................................................................................................ 7 AdoptOpenJDK 1.8.0_272-b10 ............................................................................................................ 7 Aespipe 2.4e aespipe ........................................................................................................................
    [Show full text]