Creating Seam2 ejb application on eclipse using Seam Tools and JBoss AS

Creating new Seam 2 EJB application on JBoss AS 5.1 using eclipse indigo.

My Configuration:
eclipse (indigo) with JBoss Tools installed at d:\seam-dev\eclipse
<JBOSS-AS>         JBoss AS 5.1.0 installed at D:\seam-dev\jboss-5.1.0.GA
<SEAM-HOME>      D:\jboss-seam-2.2.2.Final

Preparations:
create new workspace for eclipse
add Jboss AS 5.1 from above location to workspace (use “default” server profile)
copy hsqldb.jar from <SEAM-HOME>\lib to <JBOSS-AS>\lib folder.

Steps to create EMPTY EJB application :
1    Create new “Seam Web Project” with name Test-ent1 –> use JBoss AS 5.1 as server with default settings –>next


2    Use libaries provided by Runtime for JSF –>next


3    Application type: EAR with two modules : test-ent1-ejb and test-ent1-ear


4    Database connection : create new HSQL DB connection to database (empty database)
5    finish to create application.


6    Click on run to Run created application on JBoss AS 5.1 (data source first!  + test-ent1.ear)


NOTE: “war” module is part of “ear” so no need to run “Test-ent1” (war module) directly on server!
7    Incase if you got 404 error, just wait for server to finish loading (see server log in output panel) and then refresh page.

Steps to add “Entities”:
1    New –> New Seam
Entity : entity name: person


2    Open “Person.java” , add following two fields

 @Length(max=300)
 private String address;
 @Length(max=12,min=8)
 private String contact;

3    Generate getters and setters for them.
4    Open person.xhtml (from test-ent1 project), add follwoing lines just after “</s:decorate>”

 <s:decorate id="addressField" template="layout/edit.xhtml">
 <ui:define name="label">Address</ui:define>
 <h:inputText id="address" required="true"
 value="#{personHome.instance.address}"/>
 </s:decorate>
 <s:decorate id="contactField" template="layout/edit.xhtml">
 <ui:define name="label">Contact Number</ui:define>
 <h:inputText id="contact" required="true"
 value="#{personHome.instance.contact}"/>
 </s:decorate>

5    Open personList.xhtml page, change columns (inside <h:dataTable> )to following:

 <h:column>
 <f:facet name="header">Id</f:facet>
 #{person.id}
 </h:column>
 <h:column>
 <f:facet name="header">Name</f:facet>
 #{person.name}
 </h:column>
 <h:column>
 <f:facet name="header">Address</f:facet>
 #{person.address}
 </h:column>
 <h:column>
 <f:facet name="header">Phone number</f:facet>
 <s:link id="person"
 value="#{person.contact}"
 propagation="none"
 view="/person.xhtml">
 <f:param name="personId"
 value="#{person.id}"/>
 </s:link>
 </h:column>

6    Remove application from Server.


7    add following line inside “layout\menu.xhtml” to create menu item (only if not generated by eclipse)

 <s:link id="menuPersonListId" view="/personList.xhtml" value="Person" propagation="none"/>

8    Run application (causing un-deploy and then deploy)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s