From jbosstools-commits at lists.jboss.org Thu Jan 29 12:37:13 2009 Content-Type: multipart/mixed; boundary="===============4677765107424332317==" MIME-Version: 1.0 From: jbosstools-commits at lists.jboss.org To: jbosstools-commits at lists.jboss.org Subject: [jbosstools-commits] JBoss Tools SVN: r13347 - branches/jbosstools-3.0.0.CR2/seam/docs/reference/en. Date: Thu, 29 Jan 2009 12:37:12 -0500 Message-ID: --===============4677765107424332317== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: ochikvina Date: 2009-01-29 12:37:12 -0500 (Thu, 29 Jan 2009) New Revision: 13347 Added: branches/jbosstools-3.0.0.CR2/seam/docs/reference/en/master_output.xml Log: https://jira.jboss.org/jira/browse/JBDS-571- adding the master_output.xml; Added: branches/jbosstools-3.0.0.CR2/seam/docs/reference/en/master_output.x= ml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- branches/jbosstools-3.0.0.CR2/seam/docs/reference/en/master_output.xml = (rev 0) +++ branches/jbosstools-3.0.0.CR2/seam/docs/reference/en/master_output.xml = 2009-01-29 17:37:12 UTC (rev 13347) @@ -0,0 +1,2815 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + = + + = +]> + = + + = + Seam Dev Tools Reference Guide + AnatolyFedosik<= /author> + OlgaChikvina + SvetlanaMukhina= smukhina(a)exadel.com + = + April 2008 + + 2007 + 2008 + JBoss, a division of Red Hat Inc. + + + Version: 3.0.0.CR2 + + = + + + + PDF version + + + + + + = + + + + + + + JBoss Tools + Seam + JBDS + + + + Introduction + +
+ + What is Seam? + This introduction will help you to understand what is Seam. + Seam is a fully featu= red application framework on top of Java EE + 5. It is also one of the most popular enterprise Java framewor= k today. Seam deeply + integrates many other standard-based or open source frameworks= (e.g., JSF, EJB3, JMS, + Web Services, jBPM, JBoss Rules, Ajax4jsf, RichFaces, Facelets= , Spring, iText, Quartz, + TestNG, etc.), and provides a single programming model for dev= elopers to + "drive" those underlying frameworks via simple annotated POJOs= (Plain + Old Java Objects). It makes life easier for developers to tack= le complex enterprise + applications with many component frameworks. +
+ +
= + Installation into Eclipse + + Here, we are going to explain how to install Seam plugin int= o Eclipse. + + Seam is a one module of JBoss Tools project. Since Seam has = a dependence on other JBoss Tools modules we recommend you to install + a bundle of all JBoss Tools plug-ins. Installation instruction you= can find on JBoss Wiki in InstallingJBossTools section. + = +
+ +
+ Other relevant resources on the topic + + The Seam Framework<= /ulink> - Next generation enterprise Java development. + All latest release versions of JBoss Developer Studio/JBoss = Tools documentation you can find here. + The latest documentation builds are available here. + +
+
+ + + + + + + JBoss Tools + Seam + JBDS + + + Creating a New Seam Project via the New Seam Project wizard</ti= tle> + <para>In this chapter we provide you with the necessary steps to start= working with Seam + Framework.</para> + <para>At first, we suggest setting the specific Seam perspective that = combines a number of + different views and editors needed for work with resources concern= ed. For that select <emphasis> + <property moreinfo=3D"none">Window > Open Perspective > = Other > Seam</property> + </emphasis> or you can also access it through the button in the ri= ght top corner.</para> + + <figure float=3D"0"> + <title>Seam Perspective + + + + + + + +
+ Create standalone Seam Web Project + The best way to get started with Seam is to organise a simpl= e Seam Project and + experiment with it by creating variations. + Thus, you should select + File > New > Seam Web Pr= oject + to run the New Seam Pr= oject wizard. The wizard form + allows you to create runtime and server instances in order to = get started creating, + running, and debugging J2EE (only) applications. + Seam Web Project wizard has an option for selecting the actu= al Server (not just WTP + runtime) that will be used for the project. This allows the wi= zard to identify correctly + where the required datasource and driver libraries need to go.= + Let's get through the wizard step-by-step. First, you should= enter a name and + a location directory for your new project. +
+ New Seam Project Wizard + + + + + +
+ + + Clicking on + New... + button in the Target R= untime section will br= ing you to + another dialog. Here, you can specify a new JBoss Server Runti= me environment or the + other type of runtime appropriate for configuring your project= . Let's create one more + JBoss 4.2 Runtime. Hence, after choosing it click on + Next + button. + +
+ Specifying Target Runtime + + + + + +
+ + All what you need here is to name runtime, type the path to = its install directory or + locate it by using + Browse + button, select a Java Runtime Environment, and sel= ect which configuration + you want. + +
+ Specifying Target Runtime Configurations + + + + + +
+ + Clicking on + Finish + returns you to the New Seam Project + wizard page. The next step is to define a Server that you can do + by clicking on + New... + button in the Target S= erver section. In appear= ed New Server + dialog the last server which matches the runtime will be selected= . + + All declared runtime= s are listed in the combo box + under the servers view. Here, you can indicate a server + runtime that you need. Click + Add + if you w= ant to add a new Server Runtime. + +
+ Specifying Target Server + + + + + +
+ + Next page allows y= ou to verify the information for chosen server. + Leave everything as it is and click on + Next + . + +
+ Specifying Server Configurations + + + + + +
+ + On the last wizard= step you can modify your projects to configure them on the Server. + +
+ Project Modification for Configuring on the Server</tit= le> + <mediaobject> + <imageobject> + <imagedata fileref=3D"images/create_new_seam/create_se= am_6.png"></imagedata> + </imageobject> + </mediaobject> + </figure> + + + <para>Once you have the Target Server defined click on <emphasis> + <property moreinfo=3D"none">Finish</property> + </emphasis> button to return to the first page of the <propert= y moreinfo=3D"none"><diffmk:wrapper diffmk:change=3D"changed">New Seam Proj= ect + wizard</diffmk:wrapper></property>.</para> + + <tip> + <title>Tip: + We suggest that you look through our AS ma= nager + guide to find out more about = runtimes and servers. + + +
+ Completion of Runtime and Server Configuration + + + + + +
+ + The last section on this wizard step is Configuration. Here, you + can select one of the pre-defined project configurations eithe= r associated with Seam 1.2, Seam 2.0 or with Seam 2.1. Furthermore, you can= create your own configuration by pressing the + Modify... + button. It will open the dialog which allows to co= nfigure your own set of + facets for adding extra functionality to your project. + + Pass to the next section to find out more details on this di= alog. + +
+
+ Select the Project Facets + + The Project Facets wizard allows you to enable or disable + specific facets which define necessary characteristics for the= project. In time you + switch to this wizard form, all critical facets are already ch= ecked for the chosen + Configuration. + + Notice that this page of the wizard also allows you to set t= he necessary version for + any facet. + +
+ Project Facets Selection + + + + + +
+ + Moreover, here you can specify your own preset of selected f= acets by checking needed + ones in project facets window and clicking on + Save + button. + +
+ Specifying Custom Facet Preset + + + + + +
+ + To see all available Server runtimes click on Runtimes tab on the + left. You can create a new one using the + New + button. If more than one runtimes are checked here= , the + Make Primary + button won't be dimmed yet. So you can make use of= it to mark + primary runtime. + +
+ Runtime Manipulations + + + + + +
+ + + Ok + button will bring you to the Web Module wiza= rd form + again. +
+ +
+ How to Configure Web Module Settings + + As we deal with a Dynamic Web Application we should first s= pecify the top level + directory of our application for deploying it to a server afte= rwards. You know, this + kind of application contains both Web and Java code resources.= Thus, it's also important + to indicate the content directory as well as Java source direc= tory. The wizard will put + all those values itself. So you can leave everything as it is.= + +
+ Web Module Settings + + + + + +
+ Choose + Next + to switch to the next wizard form. +
+ +
+ Adding JSF Capabilities + + This wizard helps you to add JSF capabilities into your proj= ect for representing + appropriate behaviours associated with JSF. + Checking + Server Supplied JSF Implementa= tion + means th= at you will have a default JSF implementation given by + server. + +
+ Adding JSF Capabilities to Web Project + + + + + +
+ + In case when you want to use your custom JSF implementation = check a lower radio + button. You are able to create a library of jars by clicking o= n + New + button. + Here, it's necessary to type a L= ibrary Name, select a + Version Supported a= nd add proper Library + jars. Then click on + Finish + to complete the choice. +
+ Create JSF Implementation Library + + + + + +
+ + In the Component Libraries section of the wizard you can als= o add Component + Libraries (e.g. Richfaces). Just click on + New + button. Appeared dialog will ask you to type the L= ibrary name, supported + version and add necessary jar's. Press + Finish + to complete the choice. + +
+ Create JSF Implementation Component Library + + + + + +
+ + The last wizard options allows to edit a path for JSF Configurati= on + File, a name for JSF Servlet, JSF Serv= let + Classname and change URL Mapping Patterns. + +
+ JSF Capabilities Wizard + + + + + +
+ + Finally, as we are arranging the Seam Web project, the last = step we should do is to + adjust project configurations associated with the Seam. +
+ +
+ Configure Seam Facet Settings + + The last wizard st= ep is related to Seam facet and allows you to do the + following: +
+ Seam Facet Settings + + + + + +
+ + + + Create Seam runtime and define Seam home folder. + + + For that click on + Add + button in the General<= /property> section. Notice that in this + wizard presented below you can create a Seam runtime only for = that version which was + selected in the Project Facets= wizard (version 1.2 + in our case). + +
+ Seam Runtime Creation + + + + + +
+ + + + Select EAR or WAR deployment by checking a necessary= radio button. + + + Select a + Database Type + + + + +
+ Seam Runtime Creation + + + + + +
+ + + + and then specify a + Connection profile + appropriate for your database. + + + + +
+ Connection Profile Options + + + + + +
+ + You can edit chosen profile by using + Edit + button or organise a new one by clicking on + New + button and selecting necessary for you type of con= nection profile. +
+ Connection Profile Selecting + + + + + +
+ + On the other dialog you'll be asked to enter its name and de= scription. And + then you should select a proper driver and adjust connection d= etails. Press + Next + to preview all the adjusted settings and complete = the creation of the new + profile. + +
+ Connection Details + + + + + +
+ + The next block of settings in the Seam Facet wizard are desc= ribing a Database and a + connection to it. + In the Code Generation section the wizard have already put the + names for your Session Bean, Entity Bean and + Test packages. Of c= ourse, you can change them into the others + which you like. + +
+ Code Generation Section + + + + + +
+ + Click on + Finish + to generate a project. + + +
+
+ + + + + + + JBoss Tools + Seam + Eclipse + + + + Directory Structure of the Generated Project + + In this chapter we describe where the Seam wizard puts the gener= ated files for both EAR + and WAR deployments. + The Seam Project wizard generates projects like Eclipse WTP styl= e in order to utilize + Eclipse WTP features and to have a correct classpath. To be more p= recise it generates one + project per artifact. + +
+ WAR Deployment + + The project layout for WAR projects is: + +
+ Project Layout for WAR projects + + + + + +
+ + A WAR project can only use Seam JavaBean and JPA Entity bean= components; it cannot use + EJB3 Session beans etc. + WAR projects are generated to enable Seam 1.2.1 war hotdeplo= y feature. Classes put + into + src/action + will be deployed to + WEB-INF/dev + from which Seam 1.2.1 automatically will perform h= otdeploy of new + components. + + Note: + Because of Eclipse WTP limits the hot deployed classes a= lso existed in + WEB-INF/classes= , but since Seam gives + WEB-INF/dev + precedence it will work. + + + Furthermore the Seam Project wizard generates a test project= that is setup to run + TestNG directly against th= e proper libraries and + server runtime libraries. When the TestNG plugin is installed = you can just run your + tests via Run As > Te= stNG Test. + In order to deploy WAR project on server, right-click on the= project and select + Run As > Run on Server. Studio will deploy + WAR project into one web application on server to deploy folder. + +
+ +
+ EAR Deployment + The project layout for EAR projects is: + +
+ <diffmk:wrapper diffmk:change=3D"changed">Project Layou= t for EAR projects</diffmk:wrapper> + + + + + +
+ + An EAR project can use the whole range of Seam components, i= ncluding EJB3 Session + beans. + In order to deploy EAR project on server, right-click on the= project with + -ear postfix and se= lect + Run As > Run on Server. Studio will take care + about all modules and deploy EAR project into one enterprise a= pplication on server to + deploy folder. EAR = application keeps ejb + and war modules of the = EAR project. +
+ +
+ Renaming the Projects and Folders + + If you need to rename one of the Seam Project artifacts + (<project_name>, + <project_name>-test, + <project_name>-test or + <project_name>-ejb) or any enti= re folder like + <project_name>/WebContent, + <project_name>/ejbModule, + <project_name>-test/test-src, o= r project name in + packages org.domain.<project_name>.session, + org.domain.<project_name>.entity, you can do this + by brining the context menu and navigating + Refactor > Rename... + or just pressing + Shift + Alt + R + under the chosen resource. + + Use + Refactor > Move... + (or + Shift + Alt + V + ), if you need to move + <project_name>/WebContent folder, + <project_name>/ejbModule folder or + <project_name>/test-src folder in t= he other place + within the Project structure. +
+
+ + + + + + + JBoss Tools + Seam + JBDS + menus + actions + + + + Seam Menus and Actions + + In this chapter we provide a description of Seam actions that ar= e available from + + + Menu bar + + + Toolbar + + + Context menus in views + + + + +
+ + File Menu Actions + + In a Seam perspective, by default there are the following ac= tions in + File > New + submenu + + + Seam Actions in the New Submenu + + + + + + + + Name + + + + Function + + + + + + + + + + + + Seam Web Proje= ct + + + + + + Runs Ne= w Seam Project wizard + for creating a new Seam project + + + + + + + + + + Seam Action + + + + + + Runs New S= eam Action wizard for + creating a new Seam action + + + + + + + + + + + Seam Form + + + + + + Runs New Sea= m Form wizard for + creating a new Seam form + + + + + + + + + + Seam Entity + + + + + + Runs New S= eam Entity wizard for + creating a new Seam entity + + + + + + + + + Seam Conversat= ion + + + + + + Runs New Seam + Conversation wizard for creating a = new Seam conversation + + + + + + + + + + + Seam Generate = Entities + + + + + + Runs Generate Seam + Entities wizard + + + + + + + + + +
+ + +
+ +
+ Navigate Menu Actions + + In the next sections we are going to describe Seam actions w= hich can help you to + easily navigate through the source code. + +
+ + Find Seam References/Declarations + + To find EL expretions both in + .java + and + .xhtml + files use Find Seam References/Declarations ac= tions. For that, in the main menu bar click on + Search > Find Seam Refe= rences + or Find = Seam Declarations. + + + Look at the description of the actions in the table belo= w. + + + Find Seam References/Declarations actions + + <= /colspec> + + + + + + + + Name + + + + Function + + + + Keyboard Shortcut + + + + + + + + + + + Find Seam = References + + + Find Seam = Declarations + + + + + Find all references and declarations= to the selected element. + It's available for EL expressions in b= oth .java and .xhtml + files. Differs from normal Eclipse Fin= d References/Declarations + by showing an EL or Seam references in= the Search View. + + + + Ctrl+G + Ctrl+Shift+G + also Ctrl + 1 for .java files + + + + + + +
+ + + On the screenshot example below you could see that the s= earch results are listed + in the = + Search view. + + +
+ Find Seam Declaration for "Identity" + + + + + +
+ + You can also use Ctrl + 1 in .java files to activate the= actions: + +
+ Find Seam References for "Identity" + + + + + +
+ +
+ +
+ Open Seam Component + + To open Seam Components click on Navigate > Open Seam + Component in the main menu bar. This= dialog is also available from toolbar + icon or with hot keys combination "Ctrl+Shift+Z ". + +
+ Open Seam Components icon + + + + + +
+ + In the table below read a description about the dialog.<= /para> + + + Open Seam Components Dialog + + <= /colspec> + + + + + + + + Name + + + + Function + + + + Keyboard Shortcut + + + + + + + + + + + Open Seam = Components + + + + + + Brings up the Open Seam Component di= alog to open a component + in the editor. The Open Seam Component= selection dialog shows + all Seam components existing in the wo= rkspace. You can search + the components via their short, import= ed or full name. + + + + Ctrl+Shift+Z + + + + + + +
+ + Enter a name in the text field and see the results as it= shown on screenshot: + +
+ Open Seam Components Dialog + + + + + +
+ +
+ +
+ +
+ + + + + + + JBoss Tools + Seam + JBDS + + + = + Seam Wizards + = + This chapter introduces you with Seam Components. + All the Seam component generations options known from Seam-gen a= re available as wizards (with sensible auto-defaulting) + for creating various common Seam components: + = + + Seam Action= + Seam Form + Seam Entity= + Seam Conversation + + = + Go to File > New and select the component wizard. + = +
+ Seam Component Wizards + = + + + + +
+ = + The wizards create multiple resources and place it in the ap= propriate folders depending on your project structure (WAR or EAR). + Let's create a WAR project using the New Seam Project wizar= d. + +
+ Seam Project WAR Deployment + = + + + + +
+ = + After the project is created you need deploy it on server. + = + = +
+ = + New Seam Action + + In this and following sections you can see example creating = Seam Components. + To create a New Seam Action you should select a necessary pr= oject, type a name for Seam component, POJO class, + Method, Page and select a Packa= ge using Browse= button. + = +
+ New Seam Action Wizard + = + + + + +
+ = + You can see the action page in W= ebContent folder. Click on it to open in JBoss Tools HTML Editor= . + = +
+ Action Page in JBoss Tools HTML Editor. + = + + + + +
+ = + = + + Note: + You don't need to restart the server to see how the acti= on component works. Just use context menu = + Run As > Run On S= erver. + + = + Action component was hot-deployed. Forms and Conversations w= ill work the same way. + = +
+ Action Component + = + + + + +
+ + + = +
+
+ New Seam Form + + Click on actionMethod= in the internal browser and add a form in your project using the New Seam = Form wizard = + File > New > Seam = Form. + Select a necessary project, type a name for Seam component, POJO cla= ss, + Method, Page and select a Packa= ge using Browse= button. + = +
+ New Seam Form Wizard + = + + + + +
+ = + The Form Page was created in Web= Content folder. + = +
+ Form Page in JBoss Tools HTML Editor. + = + + + + +
+ = + Deploy the form on server. Right click on Form Page, select = Run As > Run On Server.= + = +
+ Form Component + = + + + + +
+ = + Form component was hot-deployed. + = +
+ = +
+ New Seam Conversation + = + Enter some value in the text field (e.g. value1) and click on formM= ethod. + Add a conversation using the New Seam Conversation wizard = + File > New > Seam = Form. + You should select a necessary project, type a name for Seam component, POJO class, + Method, Page and select a Packa= ge using Browse= button. + = + = +
+ New Seam Conversation Wizard + = + + + + +
+ = + Conversation page was created in WebContent folder. + = +
+ Conversation Page in JBoss Tools HTML Editor. + = + + + + +
+ = + Right click on Conversation page, select Run As > Run On Server. + = +
+ Conversation Component + = + + + + +
+ = + Conversation component was hot-deployed. + Click on Begin and Increment buttons to check the convers= ation functionality. + = +
+ = + = +
+ New Seam Entity + = + Entities cannot be hot-deployed, so we need to stop the server= . + Create an Entity using the New Entity wizard File > New > Seam Entity. + = + You should select a necessary project, type a name for Entity class, select a = + Package using Browse button, type a na= me for Master Page and Page. + = +
+ New Seam Entity Wizard + = + + + + +
+ = + The Master Page and the Entity were created in WebContent folder. = + = +
+ Master Page in JBoss Tools HTML Editor. + = + + + + +
+ = + The Entity page is: + = +
+ Entity Page in JBoss Tools HTML Editor. + = + + + + +
+ = + Run the Entity page on server. This is what you get: + = +
+ Customer Page + = + + + + +
+ Let's create two customers c1 and c2. Enter the name in t= he text field and press the Save but= ton. = + Customer should be successfully created. Press Done. Do the same for c= 2 customer. The result should be: + = +
+ Two Customers Are Created + = + + + + +
= +
= +
+ + + = + + + + JBoss Tools + Seam + JBDS + + + = + Seam Generate Entities + = + The main purpose of this chapter is to tell you about Seam Gener= ate Entities. + Generate Entities is available directly from within Eclipse usin= g Hibernate Tools plugin for the standard seam-gen generation. + Generate Entities generates a set of CRUD Seam components and we= b pages based on existing tables in a database or on existing entities in y= our application. + = + = +
+ Generate Seam Entities Wizard + = + + + + +
+ = + In the Generate Seam Entities wizard there are two generation mo= des: Reverse Engineer from database + and Use existing entities. + = + The Reverse Engineer from database mode can be described in four steps: + + The wizard gets in database, extracts the tables a= nd = + their connections + On basis of this metainfomation the Entity classes= are generated into = + org.domain.project.entity package + For the entities from step 2 the classes EntityList and En= tityHome are generated + into org.domain.project.session package + The xhtml pages are generated. + + + Checking the Use existing entities mode the wizard executes only 3 and 4 steps. It generates missing c= lasses and + xhtml pages. = + + = + Read the Generate a = CRUD Database Application chapter in order to see how the Generate Seam Entities wizard can be used. + = + = +
+ + + + + + + + JBoss Tools + Seam + JBDS + + + + Seam Editors Features + + = In this chapter you will know what Seam Editors features are and how to wor= k with them. + +
+ + Content Assist + + Content Assist (Ctrl + Space) is available when using = EL variables in the following file formats: + + + JSP + + + XHTML + + + XML + + + JAVA + + + + Notice, the code c= ompletion for the Seam components shows the proposals marked with Seam icon= . + +
+ Content Assist + + + + + +
+ + + Note: + + To get Code As= sist available for an externally generated and imported project, + don't forget to enable Seam features and configure Seam Se= ttings in Project Preferenc= es. + + +
+ <diffmk:wrapper diffmk:change= =3D"added">Content Assist for components.xml</diffmk:wrapper> + + While you are editing a + components.xml + file y= ou can make use of the Content Assist for inserting needed + elements. + +
+ <diffmk:wrapper diffmk:chan= ge=3D"added">Content Assist in the component.xml Editor</diffmk:wrapper></t= itle> + <mediaobject diffmk:change=3D"added"> + <imageobject diffmk:change=3D"added"> + <imagedata diffmk:change=3D"added" fileref=3D"imag= es/seam_editors/seam_editors_1a.png"></imagedata> + </imageobject> + </mediaobject> + </figure> + + <para diffmk:change=3D"added"><diffmk:wrapper diffmk:change=3D= "added">The editor also makes code completion aware of methods/attributes f= or EntityQuery + component.</diffmk:wrapper></para> + + <figure diffmk:change=3D"added" float=3D"0"> + <title diffmk:change=3D"added"><diffmk:wrapper diffmk:chan= ge=3D"added">Content Assist for EntityQuery Component</diffmk:wrapper></tit= le> + <mediaobject diffmk:change=3D"added"> + <imageobject diffmk:change=3D"added"> + <imagedata diffmk:change=3D"added" fileref=3D"imag= es/seam_editors/seam_editors_1b.png"></imagedata> + </imageobject> + </mediaobject> + </figure> + </section> + </section> + + <section id=3D"OpenOn"> + <title>OpenOn + + OpenOn let's you easily navigate through your project wi= thout + using the Package Explorer or Project Explorer. After pressing= + Ctrl + left click + (or just F= 3) you will see a corresponding method or class. + +
+ OpenOn + + + + + +
+ +
+ +
+ Seam Validation + + Validation of various possible problematic definitions is im= plemented for Seam + applications. + + If an issue is found it will be showed in the standard Problems + View. + +
+ Seam Validation + + + + + +
+ + + In the preferences page for Seam Validator you can see and m= odify the validator + behavior. Go to + Window > Preferences > J= Boss Tools > Web > Seam > Validator + and sele= ct the severity level for the optional Seam Validator + problem. + +
+ Seam Validator Preferences + + + + + +
+ + On WTP projects va= lidation are enabled by default and thus executed automatically, but + on normal Java projects you will have to go and add the Valida= tion builder to your + project . It is available in the properties of your project un= der + Validation. The validations can be run manually by clicking + Validate via the co= ntext menu on your project which will + execute all the active WTP validations. +
+ +
+ Structured components.xml Editor + + When editing components.xml a structured tree editor is available + in addition to pure source editing. It has a graphical view (T= ree tab) and source + (Source tab). + +
+ component.xml Editor + + + + + +
+ + + Note: + + You can view and edit compon= ents.xml and other xml files + directly in the Project Explorer and Properties sheet with= out opening the + components.xml editor. + +
+ component.xml Editor + + + + + +
+ +
+ + + + + + + + + JBoss Tools + Seam + JBDS + + + = + Seam Views + = +
+ Seam Components View + = + This chapter introduces you with Seam Components View. + The Seam Components View is available from Seam perspective. It provides a list of seam componen= ts found in a project. + = +
+ Seam Components View + = + + + + +
+ = + The Seam Components View can show a components default scope= in two ways: + = + + as labels on each component (click on the tria= ngular symbol at the top of the Seam Components View page and select Scope Presentation > Label) + + = +
+ As label + = + + + + +
+ = + + as a node per scope where the components are g= rouped under a node representing its default scope. + + = +
+ As node + = + + + + +
+ = + The Seam Packages can be presented in two ways: + = + + Flat + + = +
+ Flat Presentation of Seam Packages + = + + + + +
+ = + + Hierarchical + + = +
+ Hierarchical Presentation of Seam Packages + = + + + + +
+ = + The Seam Component View can be filtered by choosing Customize View. + = +
+ Customize View + = + + + + +
+ = + Select the Seam Compon= ents from Libraries under the Filters tab. = + This will make the view ignore components defined in jars. Thi= s will hide the many built-in Seam components and leave only those that are= actually defined in the project or have been actively configured via compo= nents.xml. Therefore, deselecting the filter will show you all available co= mponents. + Selecting the Seam Com= ponents from Referenced Projects will hide the compon= ents that dependent on other project. + = +
+ Available Custimozations + = + + + + +
+ = +
+ = +
+ Project Explorer integration + = + If you don't like to have a view for every piece of informat= ion in Eclipse, the content of the Seam Components view is also available a= s a node in the built-in Project Explorer (not Package Explorer!) view in E= clipse. + = +
+ Seam Components in Project Explorer + = + + + + +
+ = +
+ = +
+ + + + + + + + JBoss Tools + Seam + Preferences + + + + Seam Preferences + + In this chapter you get to know how Seam preferences can be modi= fied during the + development process. + +
+ General Preferences + + Seam preferences can be set using the Seam preference page. = Click on + Window > Pref= erences > JBoss Tools > Web > + Seam. + + On this page you can manage the Seam Runtime. Use the approp= riate buttons to + Add more runtimes o= r to Remove those that + are not needed. + +
+ Seam Preferences Page + + + + + +
+ + Clicking on Edit butt= on you get the form where you can change the + path of Seam runtime home folder, modify name and version. Pre= ss + Finish to apply the= changes. + +
+ Edit Seam Runtime + + + + + +
+ +
+ + Validator Preferences + + Seam preference page includes a subsection Validator. See + Window > = Preferences > JBoss Tools > Web > Seam > + Validator. + On this page you can choose a severity level for the var= ious Seam validator + problems. For example, if you want to ignore the case when= component name is + duplicated expand the Componen= ts node and select + Ignore next to = Duplicate component + name. After that you won't see the error. + + +
+ Seam Validator Preference Page + + + + + +
+ + In the upper right corner of the page there is a Configure Project + Specific link. Clicking on it you get the f= orm where you can choose a + project for specific setting. Project specific configurati= on allows you to have + different validator settings for each project. Check the <= property moreinfo=3D"none">Show only + projects with project specific settings if = you want to see the + projects that have been already set. Click on Ok. + +
+ Project Specific Configuration + + + + + +
+ + You get the validator properties page for chosen project= . Check the + Enable project specific se= ttings to be able to change the + settings. + + + Note: + You can open the same page by right clicking on the = needed project in Package + Explorer, then P= roperties > Seam + Validator. + + +
+ Validator Properties Page for Chosen Project + + + + + +
+ + +
+
+ +
+ Project Preferences + + Once Seam project is created you can modify its settings. Ri= ght click on Seam project + in Project Explorer and select Properties > Seam + Settings. + This project properties page allows you to have a flexible p= roject layout. It means + that you are not restricted with a specific project structure.= You can use the Seam + wizards (New Action, Form, Entity, etc.) on Maven, command lin= e seam-gen or your own + project structure. + +
+ Properties for Seam Project + + + + + +
+ = + + Tip: + The wizard doesn't allow the renaming of the artifacts l= isted in the Seam + Settings. It's possible to do in the Package Explorer. + See Renaming t= he Projects and + Folders. + + = + Also notice, you are not required to use the New Seam Project wizard + to benefit from Seam artifact wizards. You can just enable Sea= m on your existing project + by checking Seam Support and targeting to Seam Runtime, and then + configure the folders as you want. + +
+ Properties for Seam Project + + + + + +
+ = + + Tip: + On the figure above fields for configuring Seam artifact= s are dimmed because Seam + Runtime is not selected. + + + In Seam Wizards (New Action, Form, Entity, Conversation, Gen= erate Entities) you can + get a quick access to project settings using the Settings link in + the upper right corner of each wizard. + +
+ Settings Link + + + + + +
+ + +
+ +
+ + + + + + + EAR + Seam + + + + + = + <diffmk:wrapper diffmk:change=3D"added"= >Adding Seam support to EAR project</diffmk:wrapper> + = >From this chapter you will find out how to add Seam support to EAR project<= /diffmk:wrapper> + = For example you have several WTP projects: + = + = + seamproject-ear (You can create WTP = EAR project using New -> Project -> Java EE -> Enterprise Applicat= ion Project wizard) + seamproject-ejb (You can create WTP = EJB project using New -> Project -> EJB -> EJB Project wizard) + seamproject-war (You can create WTP = WEB project using New -> Project -> Web -> Dynamic Web Project wiz= ard) + + = + <diffmk:wr= apper diffmk:change=3D"added">Tip</diffmk:wrapper> + You can add as many EJBs modules as you want just doing the same for ea= ch EJB project. + = +
+ <diffmk:wrapper diffmk:change=3D"ad= ded">WTP Projects</diffmk:wrapper> + + + + + +
+ = + = Make sure EJB and WAR are included in EAR as modules (Properties for seampr= oject-ear -> Java EE Module Dependencies) + = +
+ <diffmk:wrapper diffmk:change=3D"ad= ded">Java EE Module Dependencies</diffmk:wrapper> + + + + + +
+ = + = Make sure there is jboss-seam.jar in application.xml as well: + = +
+ <diffmk:wrapper diffmk:change=3D"ad= ded">Java EE Module Dependencies</diffmk:wrapper> + + + + + +
+ = + = + = Then include libs from EAR to EJB Manifest Class-Path (Properties for seamp= roject-ejb -> Java EE Module Dependencies) + = +
+ <diffmk:wrapper diffmk:change=3D"ad= ded">Including Libs from EAR to EJB Manifest Class-Path</diffmk:wrapper></t= itle> + <mediaobject diffmk:change=3D"added"> + <imageobject diffmk:change=3D"added"> + <imagedata diffmk:change=3D"added" fileref=3D"images/addin= g_seam_support_to_project/including_libs_from_ear_to_ejb_manifest_class-pat= h.png"></imagedata> + </imageobject> + </mediaobject> + </figure> + = + <para diffmk:change=3D"added"><diffmk:wrapper diffmk:change=3D"added">= Include libs from EAR and seamproject-ejb.jar to WAR Manifest Class-Path (P= roperties for seamproject-war -> Java EE Module Dependencies)</diffmk:wr= apper></para> = + = + <figure diffmk:change=3D"added" float=3D"0"> + <title diffmk:change=3D"added"><diffmk:wrapper diffmk:change=3D"ad= ded">Including Libs from EAR and seamproject-ejb.jar to WAR Manifest Class-= Path</diffmk:wrapper> + + + + + +
+ = + = Thus we have set our WTP EAR/EJB/WAR projects and now we are ready to add S= eam support to them: + = + = First you have to add Seam support to WAR project: Properties for seamproje= ct-war -> Seam Settings + = + = +
+ <diffmk:wrapper diffmk:change=3D"ad= ded">Adding Seam Support to WAR Project</diffmk:wrapper> + + + + + +
+ = + = + = Set seamproject-war as Main Seam project. All other settings mostly are use= d by New Seam Entity/Action/Form/Conversation/... Wizards. Thus you can set= them as you wish. + = + = Then you can add Seam support to EJB project: Properties for seamproject-wa= r -> Seam Settings + = +
+ <diffmk:wrapper diffmk:change=3D"ad= ded">Adding Seam Support to EJB Project</diffmk:wrapper> + + + + + +
+ = + = It&s important to set seamproject-war project as main Seam project ther= e. + It will allow Seam Tools to use one common Seam model for seamproject-e= jb and seamproject-war projects. + = + = The last step is to clean/build the projects + = + = That is all. You have added Seam support to your EAR project. + = +
+ <diffmk:wrapper diffmk:change=3D"ad= ded">Added Seam Support to EAR Project</diffmk:wrapper> + + + + + +
+ = +
+ + + + + + JBoss Developer Studio + Eclipse + Java + CRUD + Database Application + + + Generate a CRUD Database Application +
+ What is CRUD? + + CRUD is an acronym for = the four basic types of SQL commands: + Create + , + Read + , + Update + , + Delete + . Most applications have some kind of CRUD + functionality, and we can assume that every programmer had to = deal with + CRUD at some point.= A CRUD application is + one that uses forms to get data into and out of a database. + In the next section we will create = Seam Web application, + connect it to the HSQL database and add + CRUD support. +
+ +
+ How to create the CRUD Database Application with Seam</titl= e> + + <itemizedlist> + <listitem> + <para>First, you should <ulink url=3D"http://docs.jboss.or= g/tools/resources/">download</ulink> a database and start it by running <em= phasis> + <property moreinfo=3D"none">./runDBServer.sh</prop= erty> + </emphasis> or <emphasis> + <property moreinfo=3D"none">runDBServer.bat</prope= rty> + </emphasis> from the database directory.</para> + </listitem> + <listitem> + <para>Create a new Seam Web Project using <property morein= fo=3D"none">New Seam Project + wizard</property> or main menu <emphasis><property= moreinfo=3D"none">File > New > Seam Web + Project</property>.</emphasis></para> + </listitem> + </itemizedlist> + <figure float=3D"0"> + <title>Seam Web Project Creation + + + + + + + + + + Name your project as + crudapp, specify Target Runtime, Server and + Seam Runtime configuration. Then press + Next + and follow the next wizard steps keeping d= efault settings. + + +
+ New Seam Project Wizard + + + + + +
+ + + Tip: + Please have a look here how to create Target + Runtime and Seam Runtime in order to get started creating,= running, and debugging + J2EE applications. + + + + + On + Seam Facet + page click + New... + next to the Co= nnection profile section to + create a new Connection pr= ofile. + + +
+ Seam Facet page + + + + + +
+ + + + On New Connection Profil= e dialog select the + HSQLDB + connection profile type, name it + cruddb + and click + Next. + + + +
+ New JDBC Connection Profile + + + + + +
+ + + + On the next page click the round icon next to the + Drivers + field to select a database driver. + + +
+ New JDBC Connection Profile Database Driver + + + + + +
+ + + + Now you should see the N= ew Driver Definition dialog. On + the first tab select the + HSQLDB JBDC Driver. Underneath in the + Driver name + field you can change its name if you need.= + + +
+ Database Driver Type + + + + + +
+ + + + You may notice the note on the previous figure. It p= rompts that you should + specify the driver of the type you pointed. Set the lo= cation of the driver by + switching to the next tab and press + Add JAR/Zip + button. + + +
+ Driver Definition + + + + + +
+ + + + On the Properties tab set the + Connecti= on URL, + + Database Name + and + User ID + and click + OK. + + + +
+ Driver Definitions Properties + + + + + +
+ + + + After clicking + OK + to submit the newly created driver you can= observe and if you need + edit all specified connection details. + + +
+ Driver and Connection Details + + + + + +
+ + + + Now click + Test Connection + to be sure that connection can be establis= hed. + + + +
+ JDBC Connection is OK + + + + + +
+ + + + Validate + JDBC Connection profil= e + settings and press + Finish + or + Back + if something is wrong. + + +
+ Validate JDBC Connection settings + + + + + +
+ + + + After clicking + Finish + two projects + crudapp + and + crudapp-test + will be created. + + + +
+ CRUDAPP Seam Project + + + + + +
+ + + + Have a look at the created projects. You can expand + WEB_CONTENT= folder and open + home.xhtml = or login.xhtml with + JBoss Visual Editor. + + +
+ login.xhtml in VPE + + + + + +
+ + + + Switch to Database Devel= opment perspective with + Window->Open Perspe= ctive->Other... + and connect to the + cruddb + database. + + +
+ Connecting to the CRUDDB database + + + + + +
+ + + + Expand + cruddb + nodes to view its + Schemas, + + Tables, + + Columns + etc. + + +
+ CRUDDB Database + + + + + +
+ + + + Switch back to the Seam<= /property> perspective. From the toolbar + select + New->Seam Generate = Entities + to create a set of CRUD Seam components and web + pages based on existing tables in the database. On the= first page of + Generate Seam Entities= + wizard keep everything by default and pres= s + Next. + + + +
+ Generate Seam Entities + + + + + +
+ + + + Click + Refresh to display all the tables from the + database. + + + +
+ Dialog for Selecting Tables + + + + + +
+ + + + Now you can filter the tables. Use the + Include + button to include only necessary ones. + + + +
+ Selecting Tables + + + + + +
+ + + + Under + WebContent + folder you can find all generated xhtml + files: + + + +
+ Entities Web Pages + + + + + +
+ + + + And under + src + folder java classes are created. + + +
+ Entities Java Classes + + + + + +
+ + + + Switch to Hibernate perspective with + Window->Open Perspe= ctive->Other.... + On Hibernate C= onfigurations view expand the + crudapp + configuration. Right click on Customers and + select + Open Mapping Diagram + from the popup menu. + + +
+ Hibernate Configurations View + + + + + +
+ + + + Observe the Mapping Diag= ram opened in the editor. Here + you can see the relations between models and database = tables. For better + navigating on the diagram use the Outline view. + + + +
+ Mapping Diagram + + + + + +
+ + + + For example, select Cust= omers entity, right click and + select + Open Source File. + This will open the Customers.java file in the + java editor. You can also do this by right-clicking on= the same entity on the + Mapping Diagram. + + + +
+ Entity class from Mapping Diagram + + + + + +
+ + So far, you are ready to deploy your application to JBoss Ap= plication Server. This = + is described in the next chapter. + +
+ +
+ + + + + + + JBoss Developer Studio + Eclipse + Java + CRUD + JBoss AS + + + The CRUD Application Walkthrough + After you familiarized oneself with example of creating the CRUD= Database Application with + Seam, you can read this charter. +
+ Using CRUD Application + To run your CRUD Application you should do the following ste= ps: + + + + Run a project on the Server. + + + + On + Package Explorer View + right click on the + crudapp + project, select Run As > Run on + Server. + +
+ Run Project on Server + + + + + +
+ + Select a Server and click Finish= + +
+ Select a Server + + + + + +
+ + Home page of the + crudapp + project should appear in + Web Browser + . +
+ Home page + + + + + +
+ + After that you can use CRUD application with + "employee" database= . + + You can use internal JBDS Web Browser or your external Web B= rowser with the same link + (ht= tp://localhost:8080/crudapp/home.seam). + Click on the + Employees List + link and observe that data from + employee + database is displayed. +
+ Employees List + + + + + +
+ + Use Employees search parameters<= /property> fields to filter the selected + list. + + Press Select opposit= e one of employees. +
+ Employee details + + + + + +
+ + + Press Edit to edit e= mployee fields. + Enter + Login + and + Password + to login. (Use + "crudapp-user"/"secret" for + example) + +
+ Login page + + + + + +
+
+ Edit Employee + + + + + +
+ Fill in + firstname + and press Save. + Database will be updated. +
+
+ + + + + + + JBoss Developer Studio + JBDS + testNG + + + Using TestNG project + With the help this chapter you will get to know with TestNG. +
+ What is TestNG? + TestNG ("Testing, the= Next Generation") is a + Java unit testing framework that aims to overcome many limitat= ions of JUnit. TestNG + introduces some new functionalities that make it more powerful= and easier to use, such + as: + + + JDK 5 Annotations (JDK 1.4 is also supported with Ja= vaDoc annotations) + + + Flexible test configuration + + + Support for data-driven testing (with @DataProvider)= + + + Support for parameters + + + Allows distribution of tests on slave machines + + + Powerful execution model (no more TestSuite) + + + Supported by a variety of tools and plug-ins (Eclips= e, IDEA, Maven, + etc...) + + + Embeds BeanShell for further flexibility + + + Default JDK functions for runtime and logging (no de= pendencies) + + + Dependent methods for application server testing + + + + More information can be found on home page: www.testng.org +
+
+ + Other relevant resources on the topic + + Next-Generation Testing + with TestNG (An Interview with Cedric Beust) + + + TestNG: + The next generation of unit testing + + + Test + Categorization Techniques with TestNG + + + TestNG makes + Java unit testing a breeze + + + In + pursuit of code quality: JUnit 4 vs. TestNG + +
+
+ How to use the generated Seam-test project to run Seam test= s? + + + + Create a new Seam Web Project with EAR deployment us= ing the New Seam Project + wizard. + + + + + + After a project is created you will have the generat= ed Seam-test project that + is setup to run TestNG directly against the proper lib= raries and server runtime + libraries. + + + +
+ Seam-test Project + + + + + +
+ + + + Add Seam Action to your project via File > New > Seam + Action. + + + +
+ Seam Action Creation + + + + + +
+ + + + Fill out the wizard fields. New Seam Action wizard w= ill create resources and + place them in the appropriate folders dependent on EAR= project structure. + + + +
+ New Seam Action Wizard + + + + + +
+ + + + When Action is created you will see actionPage.xhtml in + Package Explorer view. Act= ionBean.java will be + automatically opened in Java Editor. + + + +
+ Created Action + + + + + +
+ + + + + Select ActionLocalTest.x= ml in Seam-test project and run + the test with right click Run As > TestNG + Suite. + + + +
+ Running TestNG + + + + + +
+ + The test process will start and its output will be written i= n Console View. + +
+ Test is Finished + + + + + +
+ + + + + After running TestNG you will have the test results = in + test-output + folder in Seam-test project (press F5 to r= efresh the Package + Explorer view). Open index= .html file with Web Browser or + simply use the TestNG view. + + + + The below view shows a successful run of the test. + +
+ Viewing the Test Results + + + + + +
+ + + You can see the test results in Web Browser. + +
+ Test Results in Browser + + + + + +
+ + After clicking on + ActionLocal Tests + link you will see the Results for ActionLocal Test= s. + +
+ Test Information + + + + + +
+ + Select a result on the left-hand pane and its details will b= e displayed on the + right-hand one. + +
+ ActionLocal Test Details + + + + + +
+ + Thus with Seam tooling you can easily take advantage of Test= NG framework. As you can + see, it generates its own TestNG project as a separate module = within which you can + easily monitor the tests execution and their output. + = + In conclusion, the main goal of this document is to get you = know with a full featureset + that JBoss Tools provid= es to support Seam development. Thus if you have + some questions, comments or suggestions on the topic, please f= ell free to ask in the JBoss + Tools Forum. You can also influence on how you wan= t to see JBoss Tools docs in + future leaving your vote on our page here. + = + A set of movies on Seam tooling is available here. +
+
+ + + = + --===============4677765107424332317==--