You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Markus Haspl <m....@gmail.com> on 2008/09/25 16:08:28 UTC

isVisible Problem

hi,

i have a WebPage with a lot of Panels on it. Each Panel overrides the
isVisible() method because not every Panel should be displayed on the page.
The Problem is: the constructor of each Panel (also which aren't visible) is
called and i have a lot of load on the server. So i tried to make a init()
method (add's all components to the panel) wich is only called when
isVisible==true, but then i get the errors that it couldn't find the
components on panelXX.

thanks
markus

Re: isVisible Problem

Posted by James Carman <ja...@carmanconsulting.com>.
If you don't want the panels on there, put an EmptyPanel in their
place instead of making them invisible.

On Thu, Sep 25, 2008 at 10:08 AM, Markus Haspl <m....@gmail.com> wrote:
> hi,
>
> i have a WebPage with a lot of Panels on it. Each Panel overrides the
> isVisible() method because not every Panel should be displayed on the page.
> The Problem is: the constructor of each Panel (also which aren't visible) is
> called and i have a lot of load on the server. So i tried to make a init()
> method (add's all components to the panel) wich is only called when
> isVisible==true, but then i get the errors that it couldn't find the
> components on panelXX.
>
> thanks
> markus
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: isVisible Problem

Posted by Markus Haspl <m....@gmail.com>.
thank you eric! i will change the Overrides.



On Thu, Sep 25, 2008 at 5:09 PM, Erik van Oosten <e....@grons.nl>wrote:

> Overriding isVisible can be quite evil. The problem is that it is called
> also in the detach phase. When isVisible depends on the model, your model is
> often reloaded!
>
> There are 2 solutions:
> - within method isVisible cache the result, clear the cache in the
> onDetach.
> - (recommended) don't override isVisible but do:
>
> @Override void onBeforeRender() {
>  setVisible(.....);
> }
> @Override boolean callOnBeforeRenderIfNotVisible() {
>  return true;
> }
>
> Regards,
>   Erik.
>
>
> Markus Haspl wrote:
>
>> hi,
>>
>> i have a WebPage with a lot of Panels on it. Each Panel overrides the
>> isVisible() method because not every Panel should be displayed on the
>> page.
>> The Problem is: the constructor of each Panel (also which aren't visible)
>> is
>> called and i have a lot of load on the server. So i tried to make a init()
>> method (add's all components to the panel) wich is only called when
>> isVisible==true, but then i get the errors that it couldn't find the
>> components on panelXX.
>>
>> thanks
>> markus
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: isVisible Problem

Posted by Erik van Oosten <e....@grons.nl>.
Overriding isVisible can be quite evil. The problem is that it is called 
also in the detach phase. When isVisible depends on the model, your 
model is often reloaded!

There are 2 solutions:
- within method isVisible cache the result, clear the cache in the onDetach.
- (recommended) don't override isVisible but do:

@Override void onBeforeRender() {
  setVisible(.....);
}
@Override boolean callOnBeforeRenderIfNotVisible() {
  return true;
}

Regards,
    Erik.

Markus Haspl wrote:
> hi,
>
> i have a WebPage with a lot of Panels on it. Each Panel overrides the
> isVisible() method because not every Panel should be displayed on the page.
> The Problem is: the constructor of each Panel (also which aren't visible) is
> called and i have a lot of load on the server. So i tried to make a init()
> method (add's all components to the panel) wich is only called when
> isVisible==true, but then i get the errors that it couldn't find the
> components on panelXX.
>
> thanks
> markus
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: isVisible Problem

Posted by Igor Vaynberg <ig...@gmail.com>.
call your init from this hook:

onbeforerender() {
  if (!hasbeenrendered()) { init(); }
}

-igor

On Thu, Sep 25, 2008 at 7:08 AM, Markus Haspl <m....@gmail.com> wrote:
> hi,
>
> i have a WebPage with a lot of Panels on it. Each Panel overrides the
> isVisible() method because not every Panel should be displayed on the page.
> The Problem is: the constructor of each Panel (also which aren't visible) is
> called and i have a lot of load on the server. So i tried to make a init()
> method (add's all components to the panel) wich is only called when
> isVisible==true, but then i get the errors that it couldn't find the
> components on panelXX.
>
> thanks
> markus
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org