Wicket
  1. Wicket
  2. WICKET-1323

AbstractPageableView has transient cachedItemCount, but doesn't set it to -1 on deserialization.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.1
    • Fix Version/s: 1.3.2
    • Component/s: wicket
    • Labels:
      None
    • Environment:
      Gentoo Linux / AMD64X2 / Java 6

      Description

      AbstractPageableView declares:

      private transient int cachedItemCount;

      When this is deserialized, cachedItemCount gets set to 0. This means that the method isItemCountCached() will return true on a deserialized AbstractPageableView. This, in turn, causes getCurrentPage() to return 0, even when the user is not navigating the first page.

      For me, this is causing huge problems with the paging navigator.

      My current workaround is this is to add this method to my DataView implementation:

      private Object readResolve() throws ObjectStreamException {
      final Class<?> myClass = getClass();
      final Class<?> dataView = myClass.getSuperclass();
      final Class<?> dataViewBase = dataView.getSuperclass();
      final Class<?> abstractPagableView = dataViewBase.getSuperclass();
      try

      { final Field field; field = abstractPagableView.getDeclaredField("cachedItemCount"); field.setAccessible(true); field.setInt(this, -1); }

      catch (Exception e)

      { throw new RuntimeException(e); }

      return this;
      }

      Obviously it would be better if the AbstractPagingView could take care of this itself.

        Activity

        Hide
        Benjamin Keil added a comment -

        Awesome, thanks!

        Show
        Benjamin Keil added a comment - Awesome, thanks!
        Hide
        Johan Compagner added a comment -

        i added:
        private void readObject(java.io.ObjectInputStream s) throws java.io.IOException,
        ClassNotFoundException

        { // Read in all fields s.defaultReadObject(); clearCachedItemCount(); }
        Show
        Johan Compagner added a comment - i added: private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { // Read in all fields s.defaultReadObject(); clearCachedItemCount(); }

          People

          • Assignee:
            Johan Compagner
            Reporter:
            Benjamin Keil
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development