You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@click.apache.org by Hantsy Bai <ha...@gmail.com> on 2009/11/11 15:00:05 UTC

How to make Page support mutil level inheritance...

Hi everybody,
The subpage can extends parent page via overriding the getTemplate() 
method and get all feature in the parent page ..
How to make mutil level inheritance?

For example, a Detail page in include header, content, footer section, I 
want to split content into tow area, the sidebar and the main content.]

So I design a DetailPage include header, footer, a Content page extend 
the DetailPage and  include the sidebar , the CompletePage extends the 
Content  page and include main content area.

How to implements this, if not use panel??

-- 
Hantsy Bai
Guangzhou, China
http://hantsy.blogspot.com


Re: How to make Page support mutil level inheritance...

Posted by Hantsy Bai <ha...@gmail.com>.
On 11/12/2009 04:53 PM, Bob Schellink wrote:
> Hi Hantsy,
>
> By default Click uses Velocity to implement the inheritance so only 
> one $path variable is available inside the template. However you could 
> use another variable name to implement what you want:
>
> Border.java:
> public class Border extends Page {
>     public String getTemplate() {
>         return "/border.htm";
>     }
> }
>
> border.htm:
> ...
> <!-- Parse the Sidebar template -->
> #parse($template2)
> ...
>
> Sidebar.java:
> public class Sidebar extends BorderPage {
>
>     public void onInit() {
>         String path = getContext().getPagePath(Sidebar.class);
>         addModel("template2", path);
>     }
> }
>
> Complete.java:
> public class Complete extends Sidebar {
> }
>
> complete.htm:
> ...
> #parse($path)
> ...
>
>
> You can also use Velocity #if to conditionally parse $template2 or 
> $path etc.
>
> kind regards
>
> bob
>
> Hantsy Bai wrote:
>> Hi everybody,
>> The subpage can extends parent page via overriding the getTemplate() 
>> method and get all feature in the parent page ..
>> How to make mutil level inheritance?
>>
>> For example, a Detail page in include header, content, footer 
>> section, I want to split content into tow area, the sidebar and the 
>> main content.]
>>
>> So I design a DetailPage include header, footer, a Content page 
>> extend the DetailPage and  include the sidebar , the CompletePage 
>> extends the Content  page and include main content area.
>>
>> How to implements this, if not use panel??
>>
>
>
Oh, thank you for your help...
I am an absolute Click newbie...I am beginning a new project which uses 
Click framework as presentation framework ... maybe there are  some 
problems in future...

Thank you for your patience.

-- 
Hantsy Bai
Guangzhou, China
http://hantsy.blogspot.com


Re: How to make Page support mutil level inheritance...

Posted by Bob Schellink <sa...@gmail.com>.
Hi Hantsy,

By default Click uses Velocity to implement the inheritance so only one $path variable is available 
inside the template. However you could use another variable name to implement what you want:

Border.java:
public class Border extends Page {
     public String getTemplate() {
         return "/border.htm";
     }
}

border.htm:
...
<!-- Parse the Sidebar template -->
#parse($template2)
...

Sidebar.java:
public class Sidebar extends BorderPage {

     public void onInit() {
         String path = getContext().getPagePath(Sidebar.class);
         addModel("template2", path);
     }
}

Complete.java:
public class Complete extends Sidebar {
}

complete.htm:
...
#parse($path)
...


You can also use Velocity #if to conditionally parse $template2 or $path etc.

kind regards

bob

Hantsy Bai wrote:
> Hi everybody,
> The subpage can extends parent page via overriding the getTemplate() 
> method and get all feature in the parent page ..
> How to make mutil level inheritance?
> 
> For example, a Detail page in include header, content, footer section, I 
> want to split content into tow area, the sidebar and the main content.]
> 
> So I design a DetailPage include header, footer, a Content page extend 
> the DetailPage and  include the sidebar , the CompletePage extends the 
> Content  page and include main content area.
> 
> How to implements this, if not use panel??
>