florin.g wrote:

public class ContainerPage extends Page {
   public Panel panel = new Panel('mypanel', '/myPanel.htm');
}


This looks right.


public class MyPanel extends Page {
   public String myString = "loaded and parsed inside panel";
}


This will be a problem. When ContainerPage parses its template and comes across $mypanel variable, Velocity basically invokes panel.toString(). The Panel declared inside ContainerPage does not set the myString property which is why $myString prints out "as is".

It seems you want to include the myPanel.htm template and have the MyPanel Page processed. However from Velocity's point of view it does not know about MyPanel Page. It simply prints out the myPanel.htm template and replaces any variables it finds along the way. Since MyPanel Page was not processed, myString variable is not available to Velocity.

So here is what you can do. Let MyPanel extend from Panel instead and reuse MyPanel in your pages. (Note, autobinding is only available in Pages, so you need to add variables directly for Panels):

public class MyPanel extends Panel { // Extend from Panel
    public MyPanel() {
        addModel("myString", "loaded");
    }
}


With the above change it should work. You can now include MyPanel in a second Page for reuse.

Let us know if that works.

kind regards

bob

Reply via email to