Description
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
super.onBeforeRender();
}
After:
protected void onBeforeRender()
{
if (!getFlag(FLAG_PREPARED_FOR_RENDER))
{ initFactories(); }
super.onBeforeRender();
}