Simple Blog Example
def module default {
def entity Message {
id: Id,
title: String,
author: String,
text: String
}
read title, author, text where true
write title, author, text where true
def screen list {
div title {
label "Message List"
};
iterator (row in (from (m in Message) select m)) {
label row.title + " (" + row.author + ") ";
link {
label "View"
} to view(row.id);
br
};
br; br;
div title {
label "Write Message"
};
label "Title: "; textfield title; br;
label "Author: "; textfield author; br;
label "Text: "; textfield text; br;
button "Add" to saveMessage(title, author, text)
}
def screen view(msgId: Int) {
iterator (msg in (from (m in Message) where m.id == msgId select m)){
div title {
label "'" + msg.title + "' by " + msg.author
}; br;
label msg.text
};
br; br;
link {
label "Message List"
} to list()
}
def action saveMessage(titleIn: String, authorIn: String, textIn: String): Block {
insert {
title = titleIn,
author = authorIn,
text = textIn
} in Message;
list()
}
}
Back