class templatepage extends webpage {
private boolean initialized=false;
private final RepeatingView header1,content1;
public templatepage() {
add(header1=new RepeatingView("header1"));
add(header2=new RepeatingView("content1"));
}
protected void addToHeader(Component c) { header1.add(c); }
protected void addToContent1(Component c) { content1.add(c); }
protected abstract initialize();
onBeforeRender() { if (!initialized) { initialize(); initialized=true; }
}
templatepage.html
<html><body>...
<div id="header1"><div wicket:id="header1"></div></div>
<div id="header1"><div wicket:id="content1"></div></div>
<wicket:child/><!-- needed for markup inheritance -->
</body>
</html>
class page1 extends templatepage {
initialize() {
addToHeader1(new HeaderPanel("panel"));
Fragment f=new Fragment("1","contentfrag");
f.add(new Label("hello","hello"));
addToContent1(f);
}
}
page1.html
<wicket:extend>
<wicket:fragment wicket:id="contentfrag">
<div wicket:id="hello"></div>
</wicket:fragment>
</wicket:extend>
you can add two types of components into those containers: panels and
fragments. if you use a fragment then you have to define its markup in the
page's html.
-igor
On 5/15/07, Fábio Bombonato <[EMAIL PROTECTED]> wrote:
Hi Folks,
I´m newbie in Wicket, but until last week I trying to figure out how to
organize the code and html markup with wicket to get a template page to
work. Let me explain,
I´m want to create a Template web page that contains markup´s that I
called "containers", for example:
Template.html:
<html>
<head>
</head>
<body>
<div id="header1" wicket:id="header1"></div>
<div id="content1" wicket:id="content1"></div>
<div id="content2" wicket:id="content2"></div>
</body>
</html>
In this "containers" I could insert many components in each one, or simple
no one, depends on which web page will use this template.
Than, I create a web page to use the "containers" of theTemplate.html and
insert in it the components that I want. For example,
MainPage.html
<html>
<head>
</head>
<body>
<div id="header1" wicket:id="header1">
<span wicket:id="login"></span>
</div>
<div id="content1" wicket:id="content1">
<span wicket:id="lastNews"></span>
</div>
<div id="content2" wicket:id="content2">
<span wicket:id="blogContent"></span>
</div>
</body>
</html>
In above example I repeat the Template html code to exemplify the
situation, however the problem is that I don´t want to repeat the Template
page all time to create some web page, I want to reuse the template web page
and not repeat that in sub pages. The template page is used for all the
pages, so it´s easy if the design is centralized in that template page the
only place that I need to modify that design if I want to change the main
template page and not in all sub pages. Reading the Maillist, the people
call this the "Dreamweaver centric".
Remembering, the pages that use template could change the components used
in it. For example:
UserProfilePage.html
<html>
<head>
</head>
<body>
<div id="header1" wicket:id="header1">
<span wicket:id="showAd"></span>
</div>
<div id="content1" wicket:id="content1">
<span wicket:id="userProfileDetails"></span>
</div>
<div id="content2" wicket:id="content2">
<span wicket:id="lastUsers"></span>
</div>
</body>
</html>
Note that all "components" was changed. So, it´s not the simple Header,
Content and Footer centric, which header and footer is static, but all parts
in the containers could be changed. Them, use the markup inheritance and
<wicket:child /> it isn´t sufficient, because all content could change and
not a specific part (like only the Content part).
Read some topics in Wicket WiKi, I searched and readed many topics in
maillist, like:
Border and markup inheritance problem
http://www.nabble.com/Border-and-markup-inheritance-problem-t1639150.html#a4475258
Inheritance and <wicket:child /> inside a tag with wicket:id
http://www.nabble.com/Inheritance-and-%3Cwicket%3Achild--%3E-inside-a-tag-with-wicket%3Aid-tf1811521.html#a4936866
More than one <wicket:child>
http://www.nabble.com/More-than-one-%3Cwicket%3Achild%3E-tf3584957.html#a10017716
I´m little lost ;-), The problem is that I couldn't´t figure out what I
need to use and how implement something to do this. I don´t know if a need
to use wicket Panels, Borders, Fragments or perhaps MarkupContainer. In the
end, I think it´s necessary to group many panels, but I don´t know how.
I really, really appreciate some simple example.
Thanks for any help,
and excuse me for my bad English.
--
Bombonato
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user