Iterating a map in sightly which have custom object as key
Hi All,
(Similar issue to mine: http://coderissues.com/questions/31437688/how-to-traverse-a-map-having-keys-of-object-type-using-sightly )
I am having tough time iterating a custom map in sightly, previously I have iterated through normal map<String, String> many type in sightly and it worked perfectly fine.
My custom map Map<Product, List<CartEntry>>, As I am using Product as key to my map I have overridden the equals and hashcode method for my product class as below. I am able to iterate the map in normal java class and able to output the required values. But when I trying to iterate it in sightly it is failing and saying error as invalid key.
<div data-sly-list.parentEntry="${shoppingCart.cartItems}" data-sly-unwrap>
<div data-sly-list.childEntry="${shoppingCart.cartItems[parentEntry]}" data-sly-unwrap>
${childEntry.productCode}
</div>
</div>
@Override
public int hashCode()
{
return this.code.hashCode();
}
@Override
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final Product other = (Product) obj;
if (this.code != other.getCode())
{
return false;
}
return true;
}
Not sure how sightly has implemented data-sly-list? So it is possible to iterate this kind of map in sightly?
Any hints would be greatly appreciated,
Kind regards,
Shehjad