GettingStarted

From DaamWiki

Jump to: navigation, search

Getting started with DAAM.

The example project

The example project is bundled with the release and serves as a small benchmark showing the capabilities of the framework. It can be imported into Eclipse as a standard Java project, and the EAR can be built using the build script (nb: the build script currently doesn't compile the source files). The deployment directory is set in the build.properties file. The EAR runs in JBoss, it was tested with 4.2.2GA. It needs a datasource available in the "java:/CbwDS" jndi name, as configured in persistence.xml. To create the initial database, just set hbm2ddl.auto property to "create" for one deployment. To get started with the framework, it's best just to play around in this example project.

Creating your own project

The steps to create your own project may vary according to your preferred project layout and third party systems. The Deployment section describes what you exaclty have to have in your deployment descriptors to get things work.

To create a main screen, we just create a SEAM component:

import javax.annotation.PostConstruct;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import daam.ui.AbstractContainerComponent;
import daam.ui.Label;

@Name("testScreen")
@Scope(ScopeType.SESSION)
public class TestScreen extends AbstractContainerComponent {

    @PostConstruct
    public void init() {
        addControl(new Label("hello world"));
    }

    @Override public void remove() {}

}

And of course have this component name configured in our web.xml:

    <servlet>
        <servlet-name>daamservlet</servlet-name>
        <servlet-class>daam.DaamServlet</servlet-class>
        <init-param>
            <param-name>rootContainer</param-name>
            <param-value>testScreen</param-value>
        </init-param>
    </servlet>

Let's add a button:

		addControl(new Button("Click me", this, "buttonClicked"));

And show a message box when the button is clicked:

	public void buttonClicked() {
		addWindow(new MessageBox("Info", "The button was clicked", Type.ok));
	}

[...]