Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-1890

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.3.4
    • 1.3.6, 1.4-RC2
    • wicket
    • None

    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

      { initFactories(); }
      super.onBeforeRender();
      }


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

      super.onBeforeRender();
      }

      Attachments

        Activity

          People

            ivaynberg Igor Vaynberg
            jvaudry James Vaudry
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified