pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Brown <gk_br...@verizon.net>
Subject Re: TreeView issue on Element Selection
Date Thu, 14 Apr 2011 13:13:51 GMT
I have fixed this. There were a couple of issues involved, both fairly minor. TreeView determines
the path to a node by calling indexOf() on the node's ancestry. There was a bug in org.apache.pivot.xml.Element#equals()
that caused equals() to return true for elements that were not actually equal, and so only
the first matching node was being selected.

However, fixing this bug did not fully solve the problem because it would ultimately prevent
duplicate elements from being used in the same tree branch. This seems like an unreasonable
restriction, especially for unsorted content. So, my solution was to remove equals() and hashCode()
from the Element class and rely on the default reference equality implementation. I think
this is valid but please let me know if you disagree.

G

On Apr 13, 2011, at 7:58 PM, Thomas Grimaud wrote:

> I did a quick example just with the filled  TreeView.
> 
> 
> 
> 2011/4/13 Greg Brown <gk_brown@verizon.net>
> Any chance you could provide a simple working example using the data you generate below
to help diagnose the problem?
> 
> On Apr 12, 2011, at 9:39 PM, Thomas Grimaud wrote:
> 
> > Hi,
> >
> > Using the demo "XML Viewer", I did my own parser in order to pick up only  informations
that I need (as I'm working with a structured xsd file I don't want to display all the content
of the file)
> > Basically for the file I'm working on, the result after the parsing is the same
as that :
> >
> > public static Element hardBuildTree(){
> >               Element ret = new Element("invoice");
> >
> >               Element header = new Element("header");
> >               Element items = new Element("items");
> >               Element item = new Element("item");
> >               items.add(item);
> >               Element total = new Element("total");
> >
> >               header.add(new Element("document_type_desc_1"));
> >               header.add(new Element("document_type_desc_2"));
> >               header.add(new Element("company_name"));
> >               header.add(new Element("company_address_1"));
> >               header.add(new Element("company_address_2"));
> >               header.add(new Element("company_address_3"));
> >               header.add(new Element("abn"));
> >               header.add(new Element("acn"));
> >               header.add(new Element("document_number"));
> >               header.add(new Element("document_date"));
> >               header.add(new Element("customer_number"));
> >               header.add(new Element("customer_name"));
> >               header.add(new Element("customer_address_1"));
> >               header.add(new Element("customer_address_2"));
> >               header.add(new Element("customer_address_3"));
> >               header.add(new Element("delivery_name"));
> >               header.add(new Element("delivery_address_1"));
> >               header.add(new Element("delivery_address_2"));
> >               header.add(new Element("delivery_address_3"));
> >               header.add(new Element("location_number"));
> >               header.add(new Element("supplier_number"));
> >               header.add(new Element("reference"));
> >
> >               item.add(new Element("item_code"));
> >               item.add(new Element("line_number"));
> >               item.add(new Element("item_code"));
> >               item.add(new Element("item_desc_1"));
> >               item.add(new Element("item_desc_2"));
> >               item.add(new Element("item_reference"));
> >               item.add(new Element("item_quantity"));
> >               item.add(new Element("item_unit"));
> >               item.add(new Element("item_unit_cost"));
> >               item.add(new Element("item_extended_amount"));
> >               item.add(new Element("item_amount"));
> >               item.add(new Element("item_tax_code"));
> >               item.add(new Element("item_tax_amount"));
> >               item.add(new Element("item_discount_percent"));
> >               item.add(new Element("item_discount_amount"));
> >
> >               total.add(new Element("total_amount"));
> >               total.add(new Element("total_extended_amount"));
> >               total.add(new Element("total_tax_amount"));
> >
> >               ret.add(header);
> >               ret.add(items);
> >               ret.add(total);
> >
> >               return ret;
> >       }
> >
> >
> > I'm using the same Node Renderer as the demo, and the display is working fine.
> >
> > My issue is that most of my elements are not selectable: I can browse the tree until,
for example, all the elements in the item branch but there i can only select the first element
(item_code), but all the other elements are not selectable.
> > If I use directly, like for the demo, the result of the function readObject of the
XmlSerialiser everything is working fine, but as soon as I try to manipulate the data in order
to build my own list it doesn't work.
> > So I guess that my Element tree is not build properly but I can't find what I'm
doing wrong.
> >
> >
> > Could you please help?
> >
> > Regards,
> >
> > Thomas
> 
> 
> <xmlTreeView.zip>


Mime
View raw message