Ticket #1163 (closed issue: fixed)

Opened 14 months ago

Last modified 14 months ago

Table column reordering

Reported by: Henri Kerola Owned by: Jani Laakso
Priority: undefined Milestone: 4.0.4-rc4
Component: undefined Version: 4.0.4
Keywords: Cc:
Known Issue description:
Hours estimate: Deadline (dd.mm.yyyy): 22.11.2007
Known Issue version (since): Known Issue title:
Hours done: Depends to:
Affects documentation: no
Known Issue workaround:
Affects release notes: yes Contract:

Description

Reordering table's columns by drag-and-drop fails when Column property id is not a String.

Problem is in Table's changeVariables method (line 1354) which throws java.lang.ArrayStoreException?:

      if (this.isColumnReorderingAllowed()) {
           if (variables.containsKey("columnorder")) {
               try {
                   Object[] ids = (Object[]) variables.get("columnorder");
                   for (int i = 0; i < ids.length; i++) {
                	   ids[i] = columnIdMap.get(ids[i].toString()); // Throws java.lang.ArrayStoreException
                   }
                   this.setColumnOrder(ids);
               } catch (Exception ignored) {
               }
           }
       }

For example the following code fixes the problem:

if (this.isColumnReorderingAllowed()) {
           if (variables.containsKey("columnorder")) {
               try {
                   Object[] ids = (Object[]) variables.get("columnorder");
                   LinkedList newVC = new LinkedList();
                   for (int i = 0; i < ids.length; i++) {
                	   //ids[i] = columnIdMap.get(ids[i].toString());
                	   newVC.add(columnIdMap.get(ids[i].toString()));
                   }
                   //this.setColumnOrder(ids);
                   this.setColumnOrder(newVC.toArray());
               } catch (Exception ignored) {
               }
           }
       }

Change History

Changed 14 months ago by Jani Laakso

  • status changed from new to assigned

Changed 14 months ago by Henri Kerola

  • deadline_date set to 22.11.2007

Changed 14 months ago by Jani Laakso

This happens because our code implicitly creates String array, afterward we try to push non String objects (e.g. Integer objects) into it => exception occurs. I'll fix this..

Changed 14 months ago by Jani Laakso

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in [2883]

Note: See TracTickets for help on using tickets.