[Laszlo-user] Recursive classes

Adam Wolff adam at laszlosystems.com
Sun Apr 2 15:08:28 EDT 2006


One way to do this is to wrap the embedded class in a state, like 
this (untested):
    <class name="headerview">
        ...
        <attribute name="haschildren"
                value="$path{ 'subheader/last()' }"/>
        <state apply="${ Number( parent.childcount ) }">
            <headerview datapath="subheader" />
        </state>
    </class>

A slightly less natural way to model this is to collect a list of all the
subheader nodes and then hand it to a replicator. See the opttree
implementation in the incubator directory for an example of this.

A


On Apr 2, Robin wrote:

> Hi, I'm trying to do something like:
>   <class name="headerview">
>    <simplelayout axis="y" />
>    <view>
>      <resizelayout axis="x" />
>      <header datapath="title" options='releasetolayout' />
>    </view>
>    <headerview datapath="subheader" />
>   </class>
> 
> Where the kind of data it's reading from is:
> 
>    <data>
>     <title>Top title</title>
>     <subheader>
>      <title>Second title 1</title>
>      <title>Second title 2</title>
>      <subheader>
>        <title>Third title 1</title>
>        <title>Third title 2</title>
>        <title>Third title 3</title>
>      </subheader>
>     </subheader>
>    </data>
> 
> However, the call to <headerview> inside of the class definition seems to
> cause an infinite loop, and nothing shows up. What can I do about this? I
> thought that the fact that the replication would mean that no headerview
> instances are produced would stop the recursion, however I guess it's trying
> to process it when it loads, rather than when it runs.
> 
> I want to have a kind of recursive header builder, that ultimately is going to
> look something like:
> 
>                            Top title
>            Second title 1              Second title 2
>    Third title 1         Third title 2          Third title 3
> 
> Any input welcome.
> 
> Robin.
> _______________________________________________
> Laszlo-user mailing list
> Laszlo-user at openlaszlo.org
> http://www.openlaszlo.org/mailman/listinfo/laszlo-user
> 


More information about the Laszlo-user mailing list