[seam-commits] Seam SVN: r11786 - in modules/remoting/trunk/examples/model/src/main: webapp and 1 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon Dec 7 10:30:06 EST 2009


Author: shane.bryzak at jboss.com
Date: 2009-12-07 10:30:05 -0500 (Mon, 07 Dec 2009)
New Revision: 11786

Added:
   modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/import.sql
   modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/persistence.xml
   modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/seam-model-ds.xml
Modified:
   modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/CustomerAction.java
   modules/remoting/trunk/examples/model/src/main/webapp/model.html
Log:
add persistence to example


Modified: modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/CustomerAction.java
===================================================================
--- modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/CustomerAction.java	2009-12-07 14:17:26 UTC (rev 11785)
+++ modules/remoting/trunk/examples/model/src/main/java/org/jboss/seam/remoting/examples/model/CustomerAction.java	2009-12-07 15:30:05 UTC (rev 11786)
@@ -6,29 +6,35 @@
 import javax.enterprise.context.ConversationScoped;
 import javax.inject.Inject;
 import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
 
+import org.jboss.seam.remoting.annotations.WebRemote;
+
 @ConversationScoped
 public class CustomerAction implements Serializable
 {
    private static final long serialVersionUID = 8350706339578435242L;
    
-   @Inject EntityManager entityManager;
+   @PersistenceContext EntityManager entityManager;
    @Inject Conversation conversation;
    
    private Customer customer;
       
+   @WebRemote
    public void createCustomer()
    {
       conversation.begin();
       customer = new Customer();
    }
    
+   @WebRemote
    public void editCustomer(Integer customerId)
    {
       conversation.begin();
       customer = entityManager.find(Customer.class, customerId);
    }
    
+   @WebRemote
    public void saveCustomer()
    {
       if (customer.getCustomerId() == null)

Added: modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/import.sql
===================================================================
--- modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/import.sql	                        (rev 0)
+++ modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/import.sql	2009-12-07 15:30:05 UTC (rev 11786)
@@ -0,0 +1,3 @@
+insert into customer (customerid, firstname, lastname, dateofbirth, gender) values (1, 'Shane', 'Bryzak', '19010101', 1);
+
+

Added: modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/persistence.xml
===================================================================
--- modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/persistence.xml	                        (rev 0)
+++ modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/persistence.xml	2009-12-07 15:30:05 UTC (rev 11786)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" 
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
+   version="1.0">
+   <persistence-unit name="model">
+      <provider>org.hibernate.ejb.HibernatePersistence</provider>
+      <jta-data-source>modelDatasource</jta-data-source>
+      <properties>
+         <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+         <property name="hibernate.show_sql" value="true"/>
+         <!-- These are the default for JBoss EJB 3, but not for Hibernate EntityManager -->
+         <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
+         <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
+      </properties>
+   </persistence-unit>
+</persistence>

Added: modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/seam-model-ds.xml
===================================================================
--- modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/seam-model-ds.xml	                        (rev 0)
+++ modules/remoting/trunk/examples/model/src/main/webapp/WEB-INF/seam-model-ds.xml	2009-12-07 15:30:05 UTC (rev 11786)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE datasources
+   PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
+   "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
+<datasources>
+
+    <local-tx-datasource>
+        <jndi-name>modelDatasource</jndi-name>
+        <use-java-context>false</use-java-context>
+        <connection-url>jdbc:hsqldb:.</connection-url>
+        <driver-class>org.hsqldb.jdbcDriver</driver-class>
+        <user-name>sa</user-name>
+        <password></password>
+    </local-tx-datasource>
+
+</datasources>

Modified: modules/remoting/trunk/examples/model/src/main/webapp/model.html
===================================================================
--- modules/remoting/trunk/examples/model/src/main/webapp/model.html	2009-12-07 14:17:26 UTC (rev 11785)
+++ modules/remoting/trunk/examples/model/src/main/webapp/model.html	2009-12-07 15:30:05 UTC (rev 11786)
@@ -18,10 +18,25 @@
   <script type="text/javascript">    
     //<![CDATA[
     
+      function loadCustomer() {
+        var customerId = document.getElementById("customerId").value;
+        
+        var callback = function(result) { alert("got result: " + result); };
+        var model = new Seam.Remoting.Model();
+        
+        model.addBean("customer", "org.jboss.seam.remoting.examples.model.CustomerAction", "customer");
+        model.fetch(new Seam.Remoting.Action()
+          .setBeanType("org.jboss.seam.remoting.examples.model.CustomerAction")
+          .setMethod("editCustomer")
+          .addParam(customerId));
+      }
 
       // ]]>
-    }
-  </script>  
+  </script> 
+  
+  <label for="customerId">Customer ID</label><input type="text" id="customerId" value="1"/>
+  
+  <button onclick="javascript:loadCustomer()">Load customer</button> 
 
 
 </body>



More information about the seam-commits mailing list