in Show (sub-)totals section from display-tag demos

i think logic of code is mistake but result is correct

in here , fill map with groups

        int startIdx = 0;
        for (int i=1; i < data.size(); i++) {
final ReportableListObject value = (ReportableListObject) data.get(i);

boolean equal = value.getCity().equals(previousValue.getCity());
            if (!equal)
            {
groups.put(previousValue.getCity(), new Integer(i - startIdx));
                groups.put(value.getCity(), new Integer(0));
                previousValue = value;
                // add (1)
            }
        }

groups.put(previousValue.getCity(), new Integer(data.size() - startIdx));

and in here , add listview from groups to page

        groupList.addAll(groups.keySet());
        add(new ListView("border", groupList)
        {
            private int startIndex = 0;

            public void populateItem(final ListItem listItem)
            {
                SubtotalTable subtable = new SubtotalTable("rows", data);
                subtable.setStartIndex(startIndex);
                String group = listItem.getModelObjectAsString();
                int size = ((Integer)groups.get(group)).intValue();
                subtable.setViewSize(size);
                startIndex = size; // replace this with (2)
                listItem.add(subtable);
listItem.add(new Label("name", new PropertyModel(subtable, "group1"))); listItem.add(new Label("value", new PropertyModel(subtable, "subtotal")));
            }
        });

1- startIdx = i;
2- startIndex += size;

i suppose map of groups keep <group , its count> instead <group , endIndex>
BUT code seem that it keep latter . in other side i see setViewSize(size).

after apply 1 and 2 to code still also result is correct (groups correctly sumed)

please help ?
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to