1 / 12

JBoss Seam

JBoss Seam. Presented by Andy Nguyen Truc Pham. What is JBoss Seam?. Created by Gavin King A lightweight framework for Java EE 5.0 Provides a consistent and easy programming model for enterprise web applications. Facilitates stateful web applications development.

bonner
Download Presentation

JBoss Seam

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JBoss Seam Presented by Andy Nguyen Truc Pham

  2. What is JBoss Seam? • Created by Gavin King • A lightweight framework for Java EE 5.0 • Provides a consistent and easy programming model for enterprise web applications. • Facilitates stateful web applications development.

  3. Core Components in A Web App. • JSP • Serves as the front end • May call beans • EJB • Server side component • Performs business logic • ORM • Converts objects to database entities • Persist to and query from databases

  4. A HelloBean example • <jsp:useBean id="nameBean" class="mybeans.UserNameBean"> <jsp:setProperty name="nameBean" property="*" /> </jsp:useBean> • <HTML> <BODY> <H3> Hello <%= nameBean.getUserName() %> ! </H3> <P> The current time is <%= new java.util.Date() %>. Have a nice day! Please type in your user name: <P> <FORM METHOD=GET> <INPUT TYPE="text" NAME="username" SIZE=15> <INPUT TYPE="submit" VALUE="Enter name"> </FORM> <BODY> </HTML>

  5. A Seam Hello World example • A user enters his/her name into a web form to say Hello to Seam • Seam saves name to database • Seam displays all the names of those who had said Hello to Seam

  6. Create A Data Model @Entity@Name("person")public class Person implements Serializable {private long id;private String name;@Id @GeneratedValue 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;}}

  7. Map the Data Model to A Web Form <h:form>Please enter your name:<br/><h:inputText value="#{person.name}" size="15"/><br/><h:commandButton type="submit" value="Say Hello"action="#{manager.sayHello}"/> <h:dataTable value="#{fans}" var="fan"><h:column><h:outputText value="#{fan.name}"/></h:column></h:dataTable> </h:form>

  8. Manager Bean @Stateless@Name("manager")public class ManagerAction implements Manager {@In @Outprivate Person person;@Outprivate List <Person> fans; @PersistenceContextprivate EntityManager em;public String sayHello () {em.persist (person);person = new Person ();fans = em.createQuery("select p from Person p").getResultList();return null;}

  9. Summary Seam simplifies web application development • Intergrate Java EE frameworks • Designed for stateful web applications • Promotes the use of POJO and less XML using bijection • Configuration by exception

More Related