JBoss Seam Presented by Andy Nguyen Truc Pham
What is JBoss Seam? Created by Gavin King Created by Gavin King A lightweight framework for Java EE 5.0 A lightweight framework for Java EE 5.0 Provides a consistent and easy programming model for enterprise web applications. Provides a consistent and easy programming model for enterprise web applications. Facilitates stateful web applications development. Facilitates stateful web applications development.
Core Components in A Web App. JSP JSP Serves as the front end Serves as the front end May call beans May call beans EJB EJB Server side component Server side component Performs business logic Performs business logic ORM ORM Converts objects to database entities Converts objects to database entities Persist to and query from databases Persist to and query from databases
A HelloBean example Hello ! Hello ! The current time is. Have a nice day! Please type in your user name: The current time is. Have a nice day! Please type in your user name:
A Seam Hello World example A user enters his/her name into a web form to say Hello to Seam A user enters his/her name into a web form to say Hello to Seam Seam saves name to database Seam saves name to database Seam displays all the names of those who had said Hello to Seam Seam displays all the names of those who had said Hello to Seam
Create A public class Person implements Serializable { private long id; private public long getId() { return id;} public void setId(long id) { this.id = id; } public String getName() { return name; } public void setName(String name) {this.name = name;} } public long getId() { return id;} public void setId(long id) { this.id = id; } public String getName() { return name; } public void setName(String name) {this.name = name;} }
Map the Data Model to A Web Form Please enter your name: Please enter your name: </h:form>
public class ManagerAction implements private Person private List private EntityManager em; public String sayHello () { em.persist (person); person = new Person (); fans = em.createQuery("select p from Person p").getResultList(); return null; }
Summary Seam simplifies web application development Intergrate Java EE frameworks Intergrate Java EE frameworks Designed for stateful web applications Designed for stateful web applications Promotes the use of POJO and less XML using bijection Promotes the use of POJO and less XML using bijection Configuration by exception Configuration by exception