You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Johan Compagner <jc...@gmail.com> on 2007/08/15 17:37:20 UTC

VOTE: Component.beforeRender(): don't call onBefore when it is not visible..

in that method we do now:

        if (!getFlag(FLAG_RENDERING) && !getFlag(FLAG_PREPARED_FOR_RENDER))
        {
            setFlag(FLAG_BEFORE_RENDERING_SUPER_CALL_VERIFIED, false);

            onBeforeRender();
            getApplication().notifyComponentOnBeforeRenderListeners(this);
            if (!getFlag(FLAG_BEFORE_RENDERING_SUPER_CALL_VERIFIED))
            {
                throw new IllegalStateException(Component.class.getName() +
                        " has not been properly rendered. Something in the
hierarchy of " +
                        getClass().getName() +
                        " has not called super.onBeforeRender() in the
override of onBeforeRender() method");
            }
        }


i think we should do:

        if (isVisible() && !getFlag(FLAG_RENDERING) &&
!getFlag(FLAG_PREPARED_FOR_RENDER))
        {
            setFlag(FLAG_BEFORE_RENDERING_SUPER_CALL_VERIFIED, false);

            onBeforeRender();
            getApplication().notifyComponentOnBeforeRenderListeners(this);
            if (!getFlag(FLAG_BEFORE_RENDERING_SUPER_CALL_VERIFIED))
            {
                throw new IllegalStateException(Component.class.getName() +
                        " has not been properly rendered. Something in the
hierarchy of " +
                        getClass().getName() +
                        " has not called super.onBeforeRender() in the
override of onBeforeRender() method");
            }
        }

because calling onBeforeRender when a component isn't rendered is a bit
strange
And in onBeforeRender we now touch models and so on (for example
getModelType() of FormComponent)
which is really wrong for components that aren't visible

In the repeaters we already have the check in onBeforeRender:

protected void onBeforeRender()
    {
        if (isVisibleInHierarchy())
        {

So that for all its child components (that could be there or could be made)
the on before render isn't called anyway!

But that is visible shouldn't be needed there or done there in
onBeforeRender on all components if they aren't visible.

johan

Re: VOTE: Component.beforeRender(): don't call onBefore when it is not visible..

Posted by Janne Hietamäki <ja...@apache.org>.
+1

On Aug 15, 2007, at 6:37 PM, Johan Compagner wrote:

> in that method we do now:
>
>         if (!getFlag(FLAG_RENDERING) && !getFlag 
> (FLAG_PREPARED_FOR_RENDER))
>         {
>             setFlag(FLAG_BEFORE_RENDERING_SUPER_CALL_VERIFIED, false);
>
>             onBeforeRender();
>             getApplication().notifyComponentOnBeforeRenderListeners 
> (this);
>             if (!getFlag(FLAG_BEFORE_RENDERING_SUPER_CALL_VERIFIED))
>             {
>                 throw new IllegalStateException 
> (Component.class.getName() +
>                         " has not been properly rendered. Something  
> in the
> hierarchy of " +
>                         getClass().getName() +
>                         " has not called super.onBeforeRender() in the
> override of onBeforeRender() method");
>             }
>         }
>
>
> i think we should do:
>
>         if (isVisible() && !getFlag(FLAG_RENDERING) &&
> !getFlag(FLAG_PREPARED_FOR_RENDER))
>         {
>             setFlag(FLAG_BEFORE_RENDERING_SUPER_CALL_VERIFIED, false);
>
>             onBeforeRender();
>             getApplication().notifyComponentOnBeforeRenderListeners 
> (this);
>             if (!getFlag(FLAG_BEFORE_RENDERING_SUPER_CALL_VERIFIED))
>             {
>                 throw new IllegalStateException 
> (Component.class.getName() +
>                         " has not been properly rendered. Something  
> in the
> hierarchy of " +
>                         getClass().getName() +
>                         " has not called super.onBeforeRender() in the
> override of onBeforeRender() method");
>             }
>         }
>
> because calling onBeforeRender when a component isn't rendered is a  
> bit
> strange
> And in onBeforeRender we now touch models and so on (for example
> getModelType() of FormComponent)
> which is really wrong for components that aren't visible
>
> In the repeaters we already have the check in onBeforeRender:
>
> protected void onBeforeRender()
>     {
>         if (isVisibleInHierarchy())
>         {
>
> So that for all its child components (that could be there or could  
> be made)
> the on before render isn't called anyway!
>
> But that is visible shouldn't be needed there or done there in
> onBeforeRender on all components if they aren't visible.
>
> johan


Re: VOTE: Component.beforeRender(): don't call onBefore when it is not visible..

Posted by Igor Vaynberg <ig...@gmail.com>.
+1

-igor


On 8/15/07, Johan Compagner <jc...@gmail.com> wrote:
>
> in that method we do now:
>
>         if (!getFlag(FLAG_RENDERING) &&
> !getFlag(FLAG_PREPARED_FOR_RENDER))
>         {
>             setFlag(FLAG_BEFORE_RENDERING_SUPER_CALL_VERIFIED, false);
>
>             onBeforeRender();
>             getApplication().notifyComponentOnBeforeRenderListeners(this);
>             if (!getFlag(FLAG_BEFORE_RENDERING_SUPER_CALL_VERIFIED))
>             {
>                 throw new IllegalStateException(Component.class.getName()
> +
>                         " has not been properly rendered. Something in the
> hierarchy of " +
>                         getClass().getName() +
>                         " has not called super.onBeforeRender() in the
> override of onBeforeRender() method");
>             }
>         }
>
>
> i think we should do:
>
>         if (isVisible() && !getFlag(FLAG_RENDERING) &&
> !getFlag(FLAG_PREPARED_FOR_RENDER))
>         {
>             setFlag(FLAG_BEFORE_RENDERING_SUPER_CALL_VERIFIED, false);
>
>             onBeforeRender();
>             getApplication().notifyComponentOnBeforeRenderListeners(this);
>             if (!getFlag(FLAG_BEFORE_RENDERING_SUPER_CALL_VERIFIED))
>             {
>                 throw new IllegalStateException(Component.class.getName()
> +
>                         " has not been properly rendered. Something in the
> hierarchy of " +
>                         getClass().getName() +
>                         " has not called super.onBeforeRender() in the
> override of onBeforeRender() method");
>             }
>         }
>
> because calling onBeforeRender when a component isn't rendered is a bit
> strange
> And in onBeforeRender we now touch models and so on (for example
> getModelType() of FormComponent)
> which is really wrong for components that aren't visible
>
> In the repeaters we already have the check in onBeforeRender:
>
> protected void onBeforeRender()
>     {
>         if (isVisibleInHierarchy())
>         {
>
> So that for all its child components (that could be there or could be
> made)
> the on before render isn't called anyway!
>
> But that is visible shouldn't be needed there or done there in
> onBeforeRender on all components if they aren't visible.
>
> johan
>

Re: VOTE: Component.beforeRender(): don't call onBefore when it is not visible..

Posted by Eelco Hillenius <ee...@gmail.com>.
On 8/15/07, Eelco Hillenius <ee...@gmail.com> wrote:
> +1

Johan, could you please create a JIRA issue for such changes next time? Cheers,

Eelco

Re: VOTE: Component.beforeRender(): don't call onBefore when it is not visible..

Posted by Eelco Hillenius <ee...@gmail.com>.
+1

Eelco