SeamFramework.orgCommunity Documentation
For the most part, people interested in Forge are likely interested in creating web-applications. Thusly, this chapter will overview the basic steps to generate such an application using Forge.
Assuming you have already completed the steps to install Forge, the first thing you'll need to do is download and install JBoss Application Server 6.0 or 7.0. This server will host your application once it is built.
Next, follow these steps to create your skeleton web-application; be sure to replace any {ARGS} with your own personal values. Also keep in mind that while typing commands, you may press <TAB> at any time to see command completion options:
'forge'
from a command prompt.
$ new-project --named {name} --topLevelPackage {com.package} --projectFolder {/directory/path}
$ scaffold setupThen set up default index files, a default template and home-page. This creates the page that users will first see when accessing your application.
$ scaffold create-indexes --overwrite
$ persistence setup --provider {your JPA implementation} --container {your container}If you do not wish to use a Java EE container default data-source, you can also specify additional connection parameters such as JNDI data-source names, JDBC connection information, and data-source types. Note, however, that this means you will probably need configure your application server to provide this new data-source and/or database connection.
$ entity --named CustomerAt which point Forge should automatically pick-up the newly created entity, and will be ready to add fields.
Customer.java $ field string --named firstName Customer.java $ field string --named lastNameYou may inspect the entity using 'ls'.
Customer.java $ ls [fields] private::String::firstName; private::String::lastName; private::int::version; private::long::id; [methods] public::getFirstName()::String public::getId()::long public::getLastName()::String public::getVersion()::int public::setFirstName(final String firstName)::void public::setId(final long id)::void public::setLastName(final String lastName)::void public::setVersion(final int version)::void public::toString()::String Customer.java $
Customer.java $ scaffold from-entity No scaffold type was provided, use Forge default? [Y/n] Install which version of Metawidget? 1 - [org.metawidget:metawidget:1.0.5] 2 - [org.metawidget:metawidget:1.10] Choose an option by typing the number of the selection: 2 Install which version of Seam Persistence? 1 - [org.jboss.seam.persistence:seam-persistence:3.0.0-SNAPSHOT] 2 - [org.jboss.seam.persistence:seam-persistence:3.0.0.Final] Choose an option by typing the number of the selection: 2 Wrote /src/main/webapp/resources/forge-template.xhtml Wrote /src/main/webapp/resources/forge.css Wrote /src/main/webapp/resources/favicon.ico Wrote /src/main/java/com/scaffold/domain/Customer.java Wrote /src/main/java/com/scaffold/view/CustomerBean.java Wrote /src/main/webapp/scaffold/customer/view.xhtml Wrote /src/main/webapp/scaffold/customer/create.xhtml Wrote /src/main/webapp/scaffold/customer/list.xhtml ***SUCCESS*** Generated UI for [com.scaffold.domain.Customer] Customer.java $
$ buildOr, if you have installed Apache Maven 3.0+, and set your JBOSS_HOME environment variable to the location of your JBoss AS server installation folder, you can also build and deploy your application with the following commands.
$ mvn clean package $ mvn jboss:hard-deploy $ mvn jboss:startYour project can correspondingly be undeployed using:
$ mvn jboss:hard-undeploy $ mvn jboss:stop
http://localhost:8080/{name}-1.0.0-SNAPSHOT/
http://localhost:8080/{projectname}/faces/scaffold/{entity}/view.xhtml