From Documentation

Jump to: navigation, search




  • Author
    Maik Jablonski (maik dot jablonski (at) gmail dot com)

Maik Jablonski.jpg
Maik Jablonski, designs, develops and maintains various content-managment-systems and lots of web-applications on top of object-databases since 1999 at the University of Bielefeld (Germany).


</span>

  • Date
    November 21, 2009
  • Version
    Jease 0.2

Contents

Abstract

This smalltalk introduces you into the world of Jease - a Java-based Content-Management-Framework built on top of ZK and an popular open-source object-database of your choice (you can select between db4o, NeoDatis and Perst). Jease is an open-source framework to ease the widespread pains developing content- & database-driven web-applications with Java. Out of the box Jease provides a fully Ajax-driven Content-Management-System (CMS) as a best-practice-showcase which can easily be tailored to your specific requirements.


Jease.gif

Quickstart

Prerequisites

  • Download and install a recent Java SE Development Kit (Java SE JDK). Please note: You'll need a full Java Development Kit (JDK), a simple Java Runtime Environment (JRE) won't work.
  • Check your environment-variables: JAVA_HOME needs to point to the root-directory of your JDK.

Install

Start

  • Linux: Open a terminal and enter: jease/bin/catalina.sh run
  • Windows: Navigate to "jease -> bin" and double-click: startup (= startup.bat)

Setup

  • Open your browser and call: http://localhost:8080/cms/setup
  • Choose a name, login and password for the administration account.
  • Now you're redirected to the login-page. Enter the login and password for the newly created administrator.
  • Have fun...

Create a new Content-Type

Jease makes the creation of custom content-types (or any other user-defined data-structures) very easy and straightforward. All you have to know is a little bit Java... the use of an good IDE (like Eclipse) is strongly recommended.

  1. Write a simple Pojo as content-definition (no SQL or XML or whatever needed for this task, just declare your class in Java and you're done... kudos to the idea behind object databases for this fantastic feature)
  2. Write (better to say: programmatically declare) an appropriate content-editor which can use the wealth of existing und upcoming ZK-components
  3. Write a content-view for the website (this is optional and only needed if you want to run a public website)

Jease takes care of all the boring rest (persistence, gui, search engine, navigation, ...).

So lets start right away building a content-type to store, edit and display Events for our customized content-management-system.


Jease event.gif


Content Definition

First we have to write a Pojo which mainly declares the fields which get persisted automatically.

public class Event extends Content {

    private String announcement;
    private String location;
    private Date start;
    private Date end;

    // getter & setter
}

That's easy as it is!

Content Editor

Now we can start right away to "programmatically declare" the appropriate content-editor for Events:

public class EventEditor extends ContentEditor<Event> {

    RichTextarea announcement = new RichTextarea();
    Textfield location = new Textfield();
    Datetimefield start = new Datetimefield();
    Datetimefield end = new Datetimefield();

    public EventEditor() {
    }

    public void init() {
        add("Announcement", announcement);
        add("Location", location);
        add("Start", start);
        add("End", end);
    }

    public void load() {
        announcement.setText(getNode().getAnnouncement());
        location.setText(getNode().getLocation());
        start.setDate(getNode().getStart());
        end.setDate(getNode().getEnd());
    }

    public void validate() {
        if (announcement.isEmpty()) {
            addError("Announcement is required");
        }

        if (location.isEmpty()) {
            addError("Location is required");
        }

        if (start.isEmpty() || end.isEmpty()
                || start.getValue().after(end.getValue())) {
            addError("Date is invalid");
        }
    }

    public void save() {
        getNode().setAnnouncement(announcement.getText());
        getNode().setLocation(location.getText());
        getNode().setStart(start.getDate());
        getNode().setEnd(end.getDate());
    }

}

Content View

And last but not least we can define a JSP-Template which is responsible to render our Events nicely on our website. Please note: Jease doesn't make any assumptions about the view-technology. If you don't like JSPs, you don't have to use them. Any other technology will do also.

<%
    Event event = (Event) request.getAttribute("Node");
%>
<h1><%=event.getTitle()%></h1>
<table>
<tr>
    <td><b>Where:</b></td>
    <td><%=event.getLocation()%></td>
</tr>
<tr>
    <td><b>Start:</b></td>
    <td><%=Dates.YYYY_MM_DD_HH_MM.format(event.getStart())%></td>
</tr>
<tr>
    <td><b>End:</b></td>
    <td><%=Dates.YYYY_MM_DD_HH_MM.format(event.getEnd())%></td>
</tr>
</table>
<div><%=event.getAnnouncement()%></div>

Conclusion

If you want to develop content- or database-driven web-applications with ZK, Jease helps a lot by providing a rich infrastructure which makes development very easy. All you have to know is a little bit of Java. Have fun!

More Information

You can find more detailed documentation, screencasts, demos & support on the Jease-Homepage: http://www.jease.org/




Copyright © Maik Jablonski. This article is licensed under GNU Free Documentation License.
You got stuck here?
Let us know why!
For questions please use the forum