Wicket
  1. Wicket
  2. WICKET-5176

StringResourceModel doesn't detach model in some cases

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.8.0, 7.0.0-M1
    • Component/s: None
    • Labels:
      None

      Description

      We have come across an issue with StringResourceModel not detaching the model it holds under a certain condition. The problem is the case where the StringResourceModel is created but it is not used - for example when it is on a tab that is not displayed.

      StringResourceModel is a subclass of LoadableDetachableModel and it simply implements onDetach(), letting the superclass decide whether it is attached or not. The problem is that when StringResourceModel is created, LoadableDetachableModel.attached will be false. If the StringResourceModel is never read (i.e. getObject() is not called) the LoadableDetachableModel will not be marked as attached and when detach() is called, onDetach() will not be called. Therefore StringResourceModel will not call detach() on the model that it holds.

      1. Main.java
        1 kB
        Damien Hollis

        Activity

        Hide
        Damien Hollis added a comment -

        Attached is a very small test program that shows the issue.

        Show
        Damien Hollis added a comment - Attached is a very small test program that shows the issue.
        Hide
        Martin Grigorov added a comment -

        From now on StringResourceModel detaches its wrappedModel, defaultValue and parameters in #detach().
        Custom needs should be done in #onDetach() if needed.

        Show
        Martin Grigorov added a comment - From now on StringResourceModel detaches its wrappedModel, defaultValue and parameters in #detach(). Custom needs should be done in #onDetach() if needed.

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            Damien Hollis
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development