Palette.onBeforeRender() throws IllegalArgumentException in cases when Palette 
is invisible.
--------------------------------------------------------------------------------------------

                 Key: WICKET-1890
                 URL: https://issues.apache.org/jira/browse/WICKET-1890
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.3.4
            Reporter: James Vaudry
            Priority: Minor


Palette.onBeforeRender() conditionally adds components in initFactories() based 
on the "FLAG_HAS_BEEN_RENDERED". 

This is incorrect logic and it results in IllegalArgumentException at times. 
Instead it should check "FLAG_PREPARED_FOR_RENDER". The difference is that 
"FLAG_PREPARED_FOR_RENDER" will be true the *first time* onBeforeRender() is 
called, and no longer after that, which is what was intended. That is not the 
case for "FLAG_HAS_BEEN_RENDERED", which can be true the first time 
onBeforeRender() is called and may continue to be true on successive calls in 
the case when the Palette is invisible/hidden.

This is the opposite of http://issues.apache.org/jira/browse/WICKET-1275. In 
that bug, invisible palette components were not added, now in this bug, 
invisible palette components are added more than once. Both bugs deal with 
invisible palette.

Workaround:
--------------------------------
Subclass Palette.java and override onBeforeRender() as shown:

    protected void onBeforeRender() {
        super.onBeforeRender();
        setFlag(0x1000, true);   // Force set FLAG_HAS_BEEN_RENDERED
   }

Suggested fix:
--------------------------------

In Palette.java, change the onBeforeRender():


Before:
        protected void onBeforeRender()
        {
                if (!hasBeenRendered()) // change this
                {
                        initFactories();
                }
                super.onBeforeRender();
        }


After:
        protected void onBeforeRender()
        {
                if (!getFlag(FLAG_PREPARED_FOR_RENDER))
                {
                        initFactories();
                }
                super.onBeforeRender();
        }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to