Uploaded image for project: 'Click'
  1. Click
  2. CLK-527

FormTable sort fields are not populated for render

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5
    • 2.1.0, 2.1.0 RC1, 1.5.2
    • core
    • None

    Description

      On an instance of FormTable we have the capability to set the sorted column, sorted ascending, and page number values. These methods are inherited from the Table class but no overridden methods are provided in Form Table.

      When the form table is rendered there are hidden form fields defined which are intended to store the values of these properties but the values of these hidden fields don't ever seem to be set. These hidden fields get rendered in the startTag() method of the internal form...

      buffer.append(getForm().startTag());

      Because these fields are not populated, the submit function is not aware of any sorting that has been applied to the table and the values are often populated into the wrong underlying objects if the default sorting of the table is not the same as the explicit sorting of the table.

      I've resolved this for my application by subclassing FormTable and overriding the 3 relevant methods as follows:

      public void setSortedColumn(String columnName) {
      Field field = (Field)getForm().getFields().get(COLUMN);
      if(field != null)

      { field.setValue(columnName); }

      setSorted(false);
      super.setSortedColumn(columnName);
      }

      public void setSortedAscending(boolean ascending) {
      Field field = (Field)getForm().getFields().get(ASCENDING);
      if(field != null)

      { field.setValue("" + ascending); }

      setSorted(false);
      super.setSortedAscending(ascending);
      }

      public void setPageNumber(int pageNumber) {
      Field field = (Field)getForm().getFields().get(PAGE);
      if(field != null)

      { field.setValue("" + pageNumber); }

      super.setPageNumber(pageNumber);
      }

      These overridden methods should be in FormTable to resolve this bug. I have been working with version 1.5 so it may already be resolved in a later version.

      Note also that I am calling setSorted(false) in the first 2 methods.

      BW.

      Attachments

        Activity

          People

            sabob Bob Schellink
            bwarner Ben Warner
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: