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

FormTable setRowList twice does not display fields correctly

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Invalid
    • Affects Version/s: 2.1.0
    • Fix Version/s: None
    • Component/s: extras
    • Labels:
      None

      Description

      See following code. onPost, the table does not display the "code" field on the correct row as it's corresponding "description" field.
      This only happens if you setRowList once, then setRowList again in the one request.

      public class TestPage extends Page {
      public String msg;
      public FormTable table = new FormTable();

      public void onInit()

      { super.onInit(); table.setSortable(false); table.setClass(Table.CLASS_SIMPLE); table.getForm().setButtonAlign(Form.ALIGN_RIGHT); table.addColumn(new FieldColumn("selected", "Select", new Checkbox())); table.addColumn(new Column("description")); TextField ledgerCodeField = new TextField(); ledgerCodeField.setSize(22); table.addColumn(new FieldColumn("code", "Code", ledgerCodeField)); table.setRowList(getRowList1()); table.getForm().add(new Submit("ok", " OK ")); }

      public List getRowList1() {
      List data = new ArrayList();
      for (int i=0; i<10; i++)

      { data.add(new DataRow(false, "Item" + i, "code" + i)); }

      return data;
      }

      public List getRowList2() {
      List data = new ArrayList();
      for (int i=0; i<10; i++) {
      if (i % 2 == 0)

      { data.add(new DataRow(true, "Item" + i, "code" + i)); }

      }
      for (int i=0; i<10; i++) {
      if (i % 2 != 0)

      { data.add(new DataRow(false, "Item" + i, "code" + i)); }

      }
      return data;
      }

      public void onPost() {
      boolean valid = true;

      if (table.getForm().isValid())

      { table.getRowList().clear(); table.setRowList(getRowList2()); }

      }

      }

      public class DataRow {
      boolean selected = false;
      String description = "";
      String code = "";

      public DataRow() {

      }
      public DataRow(boolean selected, String description, String code)

      { this.selected = selected; this.description = description; this.code = code; }

      public boolean isSelected()

      { return selected; }

      public void setSelected(boolean selected)

      { this.selected = selected; }

      public String getDescription()

      { return description; }

      public void setDescription(String description)

      { this.description = description; }

      public String getCode()

      { return code; }

      public void setCode(String code)

      { this.code = code; }

      }

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              huydo Huy Do
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: