Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are two problems in your code. First, the doublequote syntax of the defaultplacement attribute:</p> <pre><code>&lt;attribute name="defaultplacement" value="'insideview'"/&gt; </code></pre> <p>That's an old syntax, which is not required with recent versions of OpenLaszlo. The other problem is the usage of the $once{} constraint, which is not even needed - and which is causing the compiler exception.</p> <pre><code>&lt;attribute name="defaultplacement" value="$once{test.defaultplacement}"/&gt; </code></pre> <p>But let me clarify what I mean using a simple code example:</p> <pre><code>&lt;canvas&gt; &lt;class name="blackbox" extends="view"&gt; &lt;attribute name="bgcolor" value="black"/&gt; &lt;attribute name="defaultplacement" value="blackinner"/&gt; &lt;view name="blackinner" bgcolor="green" x="10" y="10" width="${parent.width-20}" height="${parent.height-20}"&gt; &lt;/view&gt; &lt;/class&gt; &lt;class name="redbox" extends="view"&gt; &lt;attribute name="bgcolor" value="red"/&gt; &lt;attribute name="defaultplacement" value="content"/&gt; &lt;blackbox name="content" x="10" y="10" width="${parent.width-20}" height="${parent.height-20}"&gt; &lt;/blackbox&gt; &lt;/class&gt; &lt;redbox x="10" y="10" width="200" height="200"&gt; &lt;view width="40" height="40" bgcolor="blue" /&gt; &lt;/redbox&gt; &lt;/canvas&gt; </code></pre> <p>This example application defines a class blackbox, and a class redbox. The blackbox is just a blackbox with a green child view, which has an inset of 10 pixels.</p> <p>The redbox uses the blackbox class/tag as a child, with an inset of 20 pixels. The defaultplacement for the redbox refers to the blackbox instance, and the defaultplacement for the blackbox refers to the green child view of blackbox with the name 'blackinner'.</p> <p>The code then creates an instance of redbox, with a blue view (40x40 pixel) as the content. As you can see in this screenshot of the application, the blue view is automatically placed correctly inside the greenview of the blackbox. </p> <p><img src="https://i.stack.imgur.com/2EpjZ.png" alt="Screenshot of example application with defaultplacement working"></p> <p>The original code of your application (I've put all classes into the canvas file for simplification) compiles without any problems in 5.0 (trunk), when the discussed changes are made:</p> <pre><code>&lt;canvas&gt; &lt;class name="myframe" extends="view"&gt; &lt;attribute name="bgcolor" value="red"/&gt; &lt;attribute name="defaultplacement" value="insideview"/&gt; &lt;view x="5" y="5" width="${parent.width-10}" name='insideview' height="${parent.height-10}" bgcolor="#FFFFCC"/&gt; &lt;/class&gt; &lt;class name="answerMain" extends="view"&gt; &lt;attribute name="defaultplacement" value="test"/&gt; &lt;myframe name="test" width="220" height="20" /&gt; &lt;/class&gt; &lt;answerMain&gt; &lt;text&gt; HI &lt;/text&gt; &lt;/answerMain&gt; &lt;/canvas&gt; </code></pre> <p>The OpenLaszlo compiler should definitely not exit with an exception in such a case, but unfortunately the compiler hasn't been maintained that well in the past two years.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload