Hi Florin,

florin.g wrote:

I'd like to include a page fragment using the velocity #parse() directive.
So, I got my Page ready, my template page as well, and it works.
Then, I do a second one and it does not. If I load the fragment in the
browser it does work, /mypage.htm. Included via the #parse() method, it does
not. The debug logging does not show that the page is rendered, and the
$variables are not parsed, but displayed as simple text.


Do you mean you want to nest Pages or just templates?

If you mean Pages that won't work because Velocity #parse includes the specified template only. The associated Page object is not processed by Velocity.

If you mean nested template fragments that should work e.g.:

public MyPage extends Page {
    public MyPage() {
        addModel("fragment1", "/fragment/frag1.htm");
        addModel("fragment2", "/fragment/frag2.htm");
    }
}


/mypage.htm
  ...
  #parse($fragment1)

/fragment/frag1.htm
  ...
  #parse($fragment2);


Thing is you will have to specify all fragment variables inside your MyPage class.

However I think what you are looking for is Panels.



On the other hand, I need more than the BorderPage idea. What I want is the
ability to make "components", or "portlets" that can be included in various
pages. For instance, I have a "user list" in at least three different pages
for different audiences and I want to reduce the amount of coding and
refactoring.


Yeah sounds like a job for Panels. Panels are like mini pages in that they have their own template and model. You can easily nest and reuse panels between Pages as well. Since Panel is just a regular Container you can add Controls to it as well.

Hope this helps.

kind regards

bob

Reply via email to