3.3. Creating a new action
Task:
This task will show you how to create a simple web page with a stateless action method.
Prerequisites:
- JDK 6 (see Section 37.1, “Java Development Kit Dependencies” for details)
- JBoss Enterprise Application Platform 5.
- Ant 1.7.0.
- Recent versions of Eclipse, the JBoss IDE plug-in and the TestNG plug-in correctly installed.
- Add your JBoss installation to the Server View in Eclipse.
- JBoss Enterprise Application Platform running in debug mode.
- A command prompt in the directory where you unzipped the Seam distribution.
Procedure 3.2.
- Execute the command:
seam new-action
- Seam prompts for some information, and generates a new Facelets page and Seam component for your project.
Buildfile: build.xml validate-workspace: validate-project: action-input: [input] Enter the Seam component name ping [input] Enter the local interface name [Ping] [input] Enter the bean class name [PingBean] [input] Enter the action method name [ping] [input] Enter the page name [ping] setup-filters: new-action: [echo] Creating a new stateless session bean component with an action method [copy] Copying 1 file to C:\Projects\helloworld\src\hot\org\jboss\helloworld [copy] Copying 1 file to C:\Projects\helloworld\src\hot\org\jboss\helloworld [copy] Copying 1 file to C:\Projects\helloworld\src\hot\org\jboss\helloworld\test [copy] Copying 1 file to C:\Projects\helloworld\src\hot\org\jboss\helloworld\test [copy] Copying 1 file to C:\Projects\helloworld\view [echo] Type 'seam restart' and go to http://localhost:8080/helloworld/ping.seam BUILD SUCCESSFUL Total time: 13 seconds C:\Projects\jboss-seam>
- Since we have added a new Seam component, it is necessary to restart the exploded directory deployment. You can do this by typing
seam restart
, or by running therestart
target in the generated project'sbuild.xml
file from within Eclipse. Alternatively, you can edit theresources/META-INF/application.xml
file in Eclipse.You do not need to restart JBoss each time you change the application. - Now go to
http://localhost:8080/helloworld/ping.seam
and click the button. The code behind this action is in the projectsrc
directory. Add a breakpoint to theping()
method, and click the button again. - Finally, locate the
PingTest.xml
file in the test package, and run the integration tests with the TestNG plug-in for Eclipse. You can also run the tests withseam test
or thetest
target of the generated build.