seam framework for CRUD

2009-06-26  来源:本站原创  分类:Java  人气:316 

First, configure the data source context.xml this file on <catalina_home> the conf directory, I use the tomcat6

context.xml as follows:

<Resource name="jdbc/BBS" auth="Container"
  type="javax.sql.DataSource"
  driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
  url="jdbc:sqlserver://192.168.1.1:1433;DatabaseName=infodb1"
  username="sa" password="sa" maxActive="4" maxIdle="2"
  maxWait="5000" />

Here, I use the database is sql server2005, if changed to mysql database, then need to modify the driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
Replace the mysql database-driven.

Configuration seam of components.xml, the file is placed in WEB-INF directory.

<?xml version="1.0" encoding="UTF-8"?>
<components xmlns="http://jboss.com/products/seam/components"
 xmlns:core="http://jboss.com/products/seam/core"
 xmlns:persistence="http://jboss.com/products/seam/persistence"
 xmlns:security="http://jboss.com/products/seam/security"
 xmlns:transaction="http://jboss.com/products/seam/transaction"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://jboss.com/products/seam/core
  http://jboss.com/products/seam/core-2.1.xsd                   http://jboss.com/products/seam/persistence
  http://jboss.com/products/seam/persistence-2.1.xsd                   http://jboss.com/products/seam/transaction
  http://jboss.com/products/seam/transaction-2.1.xsd                   http://jboss.com/products/seam/security
  http://jboss.com/products/seam/security-2.1.xsd                  http://jboss.com/products/seam/components
  http://jboss.com/products/seam/components-2.1.xsd
  http://jboss.com/products/seam/spring
  http://jboss.com/products/seam/spring-2.1.xsd">
 <core:init debug="false" />
 <core:manager concurrent-request-timeout="500"
  conversation-id-parameter="cid" conversation-timeout="120000" />
 <transaction:entity-transaction entity-manager="#{em}" />
 <persistence:entity-manager-factory name="BBS" />
 <persistence:managed-persistence-context auto-create="true"
  entity-manager-factory="#{BBS}" name="em" />  

 <security:identity
  authenticate-method="#{authenticator.authenticate}" />
 <core:pojo-cache
  cfg-resource-name="#{facesContext.externalContext.context.getRealPath('/WEB-INF/cache.xml')}" />
</components>  

 Next, we write a  dao Interface

Note <transaction:entity-transaction entity-manager="#{em}" />
<persistence:entity-manager-factory name="BBS" />
<persistence: managed-persistence-context auto-create = "true"
entity-manager-factory = "# (BBS)" name = "em" /> This is something, which <persistence:entity-manager-factory name="BBS" /> Yaogen above context.xml in the "Resource name = "jdbc / BBS" "line.

Next, we write a dao interface

public interface UserDAO {
      public void saveUser(User user);
}

@Name(" UserDAO ")
@AutoCreate  

public class UserDAOImpl implements  UserDAO {
     @In
     private EntityManager em;
     public void saveUser(User user) throws PersistenceException {
               em.persist(user);
      }
}


@ In
private EntityManager em; injection came on the occasion, and do not need to write a few database connection things.

In the faces layers:

@ In

private UserDAO userDAO;

This could be introduced to operate the DAO

相关文章
  • seam framework for CRUD 2009-06-26

    First, configure the data source context.xml this file on <catalina_home> the conf directory, I use the tomcat6 context.xml as follows: <Resource name="jdbc/BBS" auth="Container" type="javax.sql.DataSource" driverCla

  • Seam framework based on the embedded ads (embedded javascript) to achieve 2010-04-17

    There are many sites offer javascript scripts for other websites to refer to their own content, such as advertising, news, etc.. Typical cases, such as "google adsense". Recently achieved with a relatively simple seam application, spent three da

  • Seam: the JSF application framework tailor-made 2010-08-13

    JavaServer Faces (JSF) is a Java ™ Web application for the first standardized user interface framework. The Seam is a powerful extension JSF application framework. In this new three-part series in the first article, they found that the complementarit

  • Seam the Seam development using a simple HelloWorld Web should be 2010-06-02

    Transfer from: http://blog.csdn.net/struts2/archive/2007/11/13/1882980.aspx Seam version of Hello World We use the Seam framework following the development of a HelloWrld example. Seam's hard not Seam itself, but rather to use the contents of the Sea

  • Seam beginning of the experience 2010-06-11

    Transfer from: http://www.evget.com/zh-CN/info/catalog/10220.html Why use Seam Seam this official documentation by doing a very good answer. To facilitate the documentation does not like to see a friend (but you can responsibly tell you that "This is

  • DHH rails combine to create the framework. DK hibernate framework to create the experience on how to become an architect 2010-08-02

    Remember that David Heinemeier Hansson created the rails framework, Gavin King Hibernate framework to create the experience, some people may not know who DHH and GK, I will introduce it introduced DHH and GK DHH: Ruby on Rails founder, has been known

  • Cluster configuration JBoss Seam 2011-01-14

    JBoss Seam framework benefited from the seamless integration and the use of EJB3, born with high clustering properties. This paper briefly describes the method the cluster configuration JBoss Seam. Configuration is as follows: The first is ready to w

  • Flex and Seam integration with GraniteDS 2011-07-06

    Are learning GraniteDS, but found little information about the more divergent the official document, nor a simple example of complete integration. After N attempts, finally pass the test tone is actually very simple, do not know why before you took s

  • Seam - 无缝集成 JSF,第 2 部分: 借助 Seam 进行对话 2012-03-09

    级别: 中级 Dan Allen ([email protected]), 高级 Java 工程师, CodeRyte, Inc. 2007 年 6 月 04 日 借助 Seam 开发有状态的 CRUD 应用程序是件轻而易举的事情.在 无缝 JSF 系列文章的第二篇中,Dan Allen 向您展示如何使用 Java™Server Faces (JSF) 和 Seam 为基于 Web 的高尔夫课程目录开发创建.读取.更新和删除用例.在此过程中,他突出强调了 Seam 对 JSF 生

  • The beginning of design and development of ERP 2009-03-26

    The development of nervous second half of last year have passed, and now finally able to let their own the rest. Looking back on last year, a process fraught with challenges, full of hardships, but also find the work fun, a lot of harvest. The first

  • The beginning of design development of the ERP 2009-03-26

    The development of nervous second half of last year have passed, and now finally able to let their own the rest. Looking back on last year, a process fraught with challenges, full of hardships, but also find the work fun, a lot of harvest. The first

  • Understanding of the definition of WebBean ---- 2010-03-29

    Gavin King in the development process of Seam framework, in order to compensate for EJB3 and JSF frameworks among the cracks, we introduced the concept of Web Beans, EJB3 and JSF will be integrated seamlessly up. WebBeans (JSR-299) submitted by WebBe

  • Hibernate Father: The upgrade to the Java EE 6 of the 2010-04-04

    Hibernate father of Gavin King [1] recommended the development of those who upgrade to the Java EE 6 platform, and that the current views of a variety of do not want to upgrade there is no basis in fact. After the release of Java EE 6, I have seen a

  • Building Web Applications for the Spring-Seam hybrid component 2010-06-02

    Transfer from: http://www.xinzhanedu.com/?thread-3405-1.html Spring and JBoss Seam framework for enterprise web application development provides different features, respectively. Spring is a JavaEE middleware framework, it is based on the abstract as

  • Distributed Application Platform Based on Web Service basics Summary 2010-09-27

    1, Web Service's profile 1, What is Web Service Web services is to build interoperable distributed applications for the new platform. Web service platform is a standard that defines how applications to achieve interoperability in the Web. You can use

  • Platform for distributed applications based on Web Service basics Summary 2010-09-27

    One, Web Service's profile 1, What is Web Service Web services is to build interoperable distributed applications of the new platform. Web service platform is a standard that defines how applications to achieve interoperability in the Web. You can us

  • Scooter Framework - Simplified Java CRUD 2010-07-27

    Scooter Framework - Simplified Java CRUD At 10:03 on the May 26, 2010 Comments] [IT168 released early Scooter Framework 1.0 RC2, it brings Java developers like Rails, RESTful Web platform. Recently, InfoQ had the honor to interview the Scooter Framew

  • Top Ten Reasons to choose Seam 2010-06-02

    Transfer from: http://doc.chinaunix.net/java/200805/161086.shtml This article from multiple perspectives, a more comprehensive summary of the advantages of Seam. 1, increasing the fastest way AJAX features In function, Ajax changes the interaction mo

  • Common development framework for J2EE Introduction 2010-08-31

    Spring Framework Spring is a J2EE development solves many common problems in a powerful framework. Spring provides a consistent method of managing business objects and to encourage the implantation of the interface programming rather than on the clas

  • Seam learning (b) seam component 2010-11-07

    1.Seam component refers to a POJO (Plain Old Java Objects). In particular, can be a JavaBean or EJB 3.0 enterprise bean. Seam does not force components are EJB, even without using EJB 3.0 compliant container, Seam everywhere considered at design time