Helma Logo
main list history
previous version  overview  next version

Version 18 by zumbrunn on 07. December 2005, 15:41


    // function at Site.views.list.control
    if (this.topics.count()) {
        that.topics = {};
        for (var topic in this.topics) {
            that.topics.name = this.topics[topic].name;
            that.topics.count = this.topics[topic].comments.count();


    <table border="1">
        <tr if="topics">
            <th lookup="true">Topic Name</th>
            <th lookup="true">Comment Count</th>
        <tr for="topics" class="rowcolor{($topics % 2)}">
            <td if="!topics$.count" lookup="true">No comments yet</td>
            <td if="topics$.count == 1" lookup="true">topics$.count comment</td>
            <td if="topics$.count > 1" lookup="true">topics$.count comments</td>
        <tr if="!topics">
            <td colspan="2" align="center" lookup="true">This list is empty</td>


    // function at Site.controls.list
    var content = {
        main : this.renderView('topiclist'views.list.render()
    var page = thisPage.renderView(Page.views.default, content);.render(content);
    return page;

The handler Site.views.list.control(that) is invoked whenever the topiclist list view is rendered. When the handler it is invoked, "that" is the object which was passed as the second parameter of renderView(view,that) the render() method or otherwise an empty/default object. It "that" is the object that will be used as the current and only accessible scope Javascript context when rendering the view.

Views would be E4X Javascript XML objects. When Helma would render these views, it would parse them for "lookup", "if" and "for" attributes and then evaluate them in the context of "that".

When parsing the "for" attributes, Helma would loop through the indicated object with <nobr>for(var $foo in foo)</nobr> and repeat the specified element with <nobr>foo$ == foo[$foo]</nobr>

When parsing the "lookup" attributes, Helma would check if a lookup handler function exists and if so would apply it to the element's content.