Hosted by SourceForge

Valid XHTML 1.0!

EuroLinux Alliance

On this page we will help you learn how to start working with Smile. This "Getting Started"-page will grow over time and, dare I say it, may eventually turn into a complete user manual!

What you need before we begin:

  • Java JRE 1.4 or higher
  • Tomcat 4.x or other Servlet 2.3 compliant container
  • JSF-API (you can copy the jsf-api.jar from the "JavaServerTM Faces v1.0 Reference Implementation Beta" at http://java.sun.com/j2ee/javaserverfaces/download.html)
  • log4j-1.2.8 (packaged with smile distribution)
  • copy the jsf-api.jar file to the WEB_INF/lib directory of your web application.
  • copy the smile0.3.x.jar file to the WEB_INF/lib directory of your web application.
  • copy the log4j-1.2.8.jar file to the WEB_INF/lib directory of your web application.
  • configure your web.xml file, here's an example:
<web-app>
    <display-name>
        Smile, the JavaServer Faces open-source implementation.
    </display-name>
    <description>
        Development web-app for smile.
    </description>

    <context-param>
        <param-name>net.sourceforge.smile.descriptor.package</param-name>
        <param-value>net.sourceforge.smile.demo</param-value>
        <description>The package where the screen descriptors are located.</description>
    </context-param>		
    <context-param>
        <param-name>net.sourceforge.smile.descriptor.postfix</param-name>
        <param-value></param-value>
        <description>The postfix to append to descriptor class names.</description>
    </context-param>
    <context-param>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>client</param-value>
        <description>state saving option. One of client,server</description>
    </context-param>

    <listener>
        <listener-class>net.sourceforge.smile.ApplicationListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>FacesServlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>FacesServlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
</web-app>

The web.xml contains two Smile specific context parameters:

  1. "net.sourceforge.smile.descriptor.package": This parameter must point to the package where you will keep your descriptor files.
  2. "net.sourceforge.smile.descriptor.postfix": This parameter contains the postfix that will be appended to the treeId in order to find the correct descriptor file(leave this param-value blank if you don't want a postfix).

Now you can start creating your pages, pages are defined as pojos(plain old java objects) in Smile. For Example to create your first hello world page, create a Java file like this:

public class HelloWorld extends UIScreen {
    private UIColumnLayout layout;
    private UIOutput label;
	
    public HelloWorld() {
        setTitle("Hello World Example...");

        layout = new UIColumnLayout(1,1);
        addChild(layout);

        label = new UIOutput();
        label.setComponentId("label");
        label.setValue("Hello World");
        layout.addChild(label);
    }
}

Copy the application to Tomcat and navigate to http://localhost:8080/<app-name>/faces/HelloWorld (replace app-name with the name of your web application).

If all went well, you should see a blank page with the text: Hello World.