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

LocalizedImageResource does not serialize locale/style fields

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.3.0-beta4
    • 1.3.0-rc1
    • wicket
    • None

    Description

      I have a page where clicking an AjaxLink causes an Image to be updated. In the onClick() method of the link I change the image via setImageResourceReference(). I then call AjaxRequestTarget.addComponent(image) to have the image rendered.

      Everything works great when the page is first loaded however if I navigate to a different page and then back again the image doesn't update the first time I click the link. The problem is that the LocalizedImageResource saves the current locale/style in transient fields when it is first created. By navigating to a different page and then back again it causes the class to get serialized and the locale and style are initialized to null. In setSrcAttribute() this code then compares the locale against the image component's locale.

      Locale l = component.getLocale();
      String s = component.getStyle();
      if (resourceKind == null ||
      (!Objects.equal(locale, component.getLocale()) || !Objects.equal(style, component
      .getStyle())))
      {
      // Get new component locale and style
      locale = component.getLocale();
      style = component.getStyle();

      // Invalidate current resource so it will be reloaded/recomputed
      resourceReference = null;
      resource = null;
      }

      Since the local in LocalizedImageResource was not serialized it never matches and my call to setImageResourceReference() is basically ignored.

      If you just remove the transient keyword from the locale and style fields it fixes the problem.

      Attachments

        Activity

          People

            knopp Matej Knopp
            johnray John Ray
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: