<OL>
Return to Reference...| Property | Description | Default |
|---|---|---|
| list | Invokes a method and expects to get an array from the method. This array provides the values to iterate over. | {oid}Array : The default method, if not overridden with a binding, is the oid label with Array appended to it. One usually uses bindings, though. |
| item | This is the iterator. It receives the values from the list. | {oid} : Names the accessor/method that will receive the successive values from the list. |
| key | The key to use when generating the URLs. You usually just want to leave this to the default. | This defaults to the current index in the list. Only mess with this if you think that you know what you are doing, as changing it will mean that from within any method invoked inside of the repeated section, item will not hold the current iteration's value, but rather will hold something else. |
A <OL> is used to create a loop inside of a template. The content that is inside of the tag will be repeated once for each element in list, with the current element of list provided to item. One typically uses this tag with a binding. The difference between this tag and the <REPEAT> tag is that a <OL> will also output beginning and ending tags for itself, while the <REPEAT> does not output any tags for itself and just repeats the content that it contains.
Typical Usage (Via A Binding):
Active Sessions, Per Server:<br/>
<ol oid="server_list">
<li>@srvr.name:</li>
<ol oid="server_session_list">
<li>sesn.last_activity</li>
</ol>
</ol>
attr_accessor :srvr, :sesn
def servers
server_list = nil
application.dbpool.getConnection do |ksdbh|
result = ksdbh.select(:Servers)
end
server_list
end
def sessions
@srvr.sessions
end
server_list {
item = srvr
list = servers
}
server_session_list {
item = sesn
list = sessions
}
Usage Without A Binding:
Active Sessions, Per Server:<br/>
<ol oid="srvr">
<li>@srvr.name</li>
<ol oid="sesn">
<li>@sesn.last_activity</li>
</ol>
</ol>
attr_accessor :srvrArray, :sesn, :sesnArray
def setup
application.dbpool.getConnection do |ksdbh|
@srvrArray = ksdbh.select(:Servers)
end
end
def srvr
@srvr
end
def srvr=(val)
@srvr = val
@sesnArray = val.sessions
end
A binding is typically used simply because it makes it easy to alter where the list of elements is coming from without having to make any changes to the template itself. One can also use an oid that describes more clearly the nature of the repetition.
Return to Reference...


