» Jease » Documentation

Want to contribute?

1970-01-01

Do you want to contribute to Jease? Writing documentation is a good place to get started and will help to get people becoming more familiar with Jease. Any contribution is appreciated.

2. Content Editor

Create an new class for the editor:

ROOT/WEB-INF/src/custom/MeetingEditor.java

The life-cycle of an editor is handled by Jease in the background, so you don't have to worry about it:

  • #init() is called to create the editor-form with the specified order of the fields.
  • #load() is called to load the editor-form-fields with the corresponding values from the persisted (or newly created) content-object.
  • #validate() is called to validate given values of the editor-form-fields.
  • #save() is called to transfer values from the editor-form-fields back to the content-object.

You can get a reference to the current selected content-object via the method #getNode() from the ContentEditor.

package custom;

import jease.cms.web.content.editor.ContentEditor;
import jfix.zk.Datetimefield;
import jfix.zk.RichTextarea;
import jfix.zk.Textfield;

public class MeetingEditor extends 
                    ContentEditor<Meeting> {

 RichTextarea topic = new RichTextarea();
 Textfield location = new Textfield();
 Datetimefield start = new Datetimefield();
 Datetimefield stop = new Datetimefield();

 public MeetingEditor() {
 }

 public void init() {
  add("Topic", topic, "Please enter topic.");
  add("Location", location);
  add("Start", start);
  add("Stop", stop);
 }

 public void load() {
  topic.setText(getNode().getTopic());
  location.setText(getNode().getLocation());
  start.setDate(getNode().getStart());
  stop.setDate(getNode().getStop());
 }

 public void validate() {
  validate(topic.isEmpty(), "Topic required");
  validate(location.isEmpty(), "Location required");
  validate(start.isEmpty() || stop.isEmpty(),
     "Date required");
  validate(start.getValue().after(stop.getValue()), 
      "Date invalid");
 }

 public void save() {
  getNode().setTopic(topic.getText());
  getNode().setLocation(location.getText());
  getNode().setStart(start.getDate());
  getNode().setStop(stop.getDate());
 }
}

Last modified on 2011-07-22 by Maik Jablonski