2. Content Editor
Create an new class:
Jease/WEB-INF/src/jease/cms/web/content/editor/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 jease.cms.web.content.editor;
import jease.cms.domain.Meeting;
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());
}
}
Please note: If you want to display a nice icon for your newly created content-type in the views of the Content-Management-System, you have to place an icon (PNG-format) with the same name as your content-type into Jease/WEB-INF/src/web/jease/cms.
Last modified on 2010-06-17 by Maik Jablonski