|
Handling User Input To enter data into Helma from a browser we first create an adequate layout for an HTML form: <form action="edit" method="post">
First Name: <input type="text" name="firstname"
value="<% this.firstname encoding="form" %>" /><br />
Last Name: <input type="text" name="lastname"
value="<% this.lastname encoding="form" %>" /><br />
e-mail: <input type="text" name="email"
value="<% this.email encoding="form" %>" />
<p />
<input type="submit" name="submit" value=" Save " />
</form>
Save this skin as edit.skin but this time in the HopObject directory (we will reveal the reason for this later).The corresponding action edit.hac looks like this it needs to be saved in the Person directory: apps/addressbook/Person/edit.hac: res.data.title = "Edit Helma Address Book Entry";
res.data.body = this.renderSkinAsString("edit");
renderSkin("html");
Now the edit links from the main resource of our address book application should work and you should see the HTML form containing the chosen HopObject's data.![]() The edit.hac / edit.skin combo works analogously to main.hac and link.skin in the previous sections. So nothing really new here except the encoding parameters in the skin markup. They avoid HTML markup entered in the database from messing up the HTML layout. Each value returned from the macro handler is encoded like it was wrapped into a encodeForm() function. Although the Save button already works, the data remains yet unchanged. The necessary code has to be added before the first line of edit.hac: if (req.data.submit) {
this.firstname = req.data.firstname;
this.lastname = req.data.lastname;
this.email = req.data.email;
this.modifytime = new Date();
res.redirect(root.href());
}
Try out to change some values and click Save afterwards you should notice the changes immediately in the list view.
... comment
|
navigation
Download
Community
Weblog
Mailing Lists
IRC Channel
Documentation
Introductions
Tools
Reference
Project
Roadmap
Bug Reporting
Source
Wiki
Tags
Updates
Related Projects
search
|
||||