I have a web page with a simple design where a NavigationPanel
contains a few links which replace the main panel with other panels.
My problem is that when I initialize this web page, it creates all of
the panels which will eventually replace a main panel (according to
the link in the NavigationPanel that the user has clicked) by calling
their constructors. Since the constructors initialize a bunch of
components and also retrieve data from a database, it takes a "long"
time to render the web page since it is also loading all of the other
panels.
Since I want to perform a kind of lazy loading (I only load the
components of the panels if the user has clicked on the corresponding
link in the NavigationPanel), I moved the code where I initialize the
components to the onBeforeRender() method instead of the constructor.
It worked fine for the first time I clicked a link but if I re-clicked
it, a wicket error would pop up since I was trying to add new
components that had already been added.
My solution was something like:
protected void onBeforeRender() {
super.onBeforeRender();
if(!firstTime) {
return;
}
// create the components used in this panel
...
firstTime = true
}
This way the components are created only if it is the first time I am
loading the panel.
My question is, is there a better or automatic way of doing this through wicket?
Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]