Prerequisites

Installing

Start the installer by running the windows native installer, or the executable jar (.jar) file by double clicking the download file. If this does not work try this on a the command line :


java -jar jzeno-[insert version number]-setup.jar

You will be guided through a typical installer. You should at least install the 'Template project'. After this you can run jZeno straight from the install folder by double clicking the run.bat file (on windows) or executing the run.sh shell script (on Linux/Unix).


Next you can check out the template project by pointing your browser to http://localhost:8080/app :


Take your time to read the welcome screen as it contains some valuable tips... Then take a look around at the existing menu options. Most are built-in screens that are used for configuring & monitoring your application. Also have a look at the Products screen as we'll be modifying this one later on...


Setting up Eclipse

Next you should start up eclipse and import the template project into your workspace. You can do this by selecting the menu option File - Import and then clicking Existing Projects into Workspace. Next you'll be prompted to specify the root directory of the project to import. You should specify the template subfolder in the jZeno installation location. You are then presented with the discovered project ('jzeno-template') and should click Finish.


Everything is now set up for you to start developing. In the next sections we'll first show you how you can change the existing products screen, and then move on to create a completely new screen from scratch.

First of all make sure you have opened the products screen in your web browser. Open the ProductScreen class in eclipse to edit it (in package net.sf.jzeno.template.screen in the rsrc folder) and modify it to add the an extra component to it :


public ProductScreen() {
    DynaLabel extraLabel = new DynaLabel("Hello World !");
    add(extraLabel);

    ...

Next you should compile your modified class (save the file - eclipse will then compile it). Now go to your web browser and press the RELOAD button. This should load the new version of the ProductScreen, and your little label should be visible in the browser.


Creating your first jZeno screen

In the net.sf.jzeno.template.screen package create a new java class in eclipse called 'GettingStartedScreen' and then edit this class as shown below :


package net.sf.jzeno.template.screen;

import net.sf.jzeno.echo.components.Screen;
import net.sf.jzeno.echo.components.Title;
import net.sf.jzeno.echo.databinding.DynaButton;
import net.sf.jzeno.echo.databinding.DynaLabel;
import net.sf.jzeno.echo.databinding.DynaTextField;

public class GettingStartedScreen extends Screen {
    private static final long serialVersionUID = 1L;
    
    private String yourName;
    
    public GettingStartedScreen() {      
        add(new Title("Getting Started"));
        
        DynaTextField nameField = new DynaTextField(getClass(), "yourName", "");
        add(nameField);
        
        DynaButton dynaButton = new DynaButton(null, null, 
                                       "actionCommand=buttonEvent,text=Push Me");
        add(dynaButton);
    }
    
    public void buttonEvent() {
        DynaLabel label = new DynaLabel("Welcome to jZeno, ");
        add(label);
        DynaLabel label2 = new DynaLabel(getClass(), "yourName", "");
        add(label2);
    }

    public String getYourName() {
        return yourName;
    }

    public void setYourName(String yourName) {
        this.yourName = yourName;
    }

    public String getHistoryTitle() {
        return "Getting Started";
    }
}

After you've finished this screen (don't forget to save/compile it) go to the Admin - Menu option to configure the jZeno menu and add a new menu item that opens your new screen ! Don't forget to apply your changes. (TIP: You can drag-and-drop your new menu item to an existing menu)

package get.started;

import net.sf.jzeno.echo.components.AbstractScreen;
import net.sf.jzeno.echo.components.Title;
import net.sf.jzeno.echo.databinding.DynaButton;
import net.sf.jzeno.echo.databinding.DynaLabel;
import net.sf.jzeno.echo.databinding.DynaTextField;

public class GettingStartedScreen extends AbstractScreen {
    private static final long serialVersionUID = 1L;
    
    private String yourName;
    
    private DynaTextField nameField;
    
    private DynaButton pushMeButton;
    
    private DynaLabel welcomeLabel;
    
    private DynaLabel nameLabel;
    
    public GettingStartedScreen() {      
        add(new Title("Getting Started"));
        
        nameField = new DynaTextField(getClass(), "yourName", "");
        add(nameField);
        
        pushMeButton = new DynaButton(null, null, 
                              "actionCommand=buttonEvent,text=Push Me");
        add(pushMeButton);
        
        welcomeLabel = new DynaLabel("Welcome to jZeno, ");
        welcomeLabel.setVisible(false);
        add(welcomeLabel);
        
        nameLabel = new DynaLabel(getClass(), "yourName", "");
        add(nameLabel);
        nameLabel.setVisible(false);
    }
    
    public void buttonEvent() {        
        welcomeLabel.setVisible(true);
        nameLabel.setVisible(true);
    }

    public String getYourName() {
        return yourName;
    }

    public void setYourName(String yourName) {
        this.yourName = yourName;
    }
}

To learn more, have a look at our How-to's section here.