Incorrect icon displayed in view that displays ICollection<T> results.

Nov 1, 2011 at 9:57 AM

I have a type (Customer) which has an IconName method.  This method always returns a valid iconname.

When I execute an action which returns an ICollection<Customer> the correct icon is displayed for each of the individual results, but the large icon at the top of the display, next to the "Query Result: Viewing x of y <Type>s" always shows the default.png image.

I have tried adding an IconName attribute to my Customer type also, but the same behaviour occurs.

The only way I can get the correct icon next to the results summary is to remove the IconName method.  Unfortunately I want to use different icons to represent the current state of the customer, so need to use the IconName method.

Nov 1, 2011 at 10:52 AM

This is an unfortunate side-effect of the way that the framework determines the icon.  If you specify an icon using the [IconName] attrbitute then it is held in the Naked Objects specification for that class and is picked up both when viewing an instance and when viewing a collection of that type.

If you specify an icon via an IconName() method then this takes priority, and means that icons are specified on an instance basis.  There is now no icon associated at class level (becsause each instance potentially has its own icon), so you get the default icon for a collection.

It should be possible to modify the framework such that IconName() has priority over [IconName] for instance display, but that it will default to [IconName] for displaying a collection.  I will raise an Issue for this  -  but it wis unlikely to be done in the next few days. Meantime your options are:

-  Fix this yourself in the source code (might be hard work)

- Temporarily use a custom view for a collection of Customers.  Just copy the StandaloneTable view into a Customer folder within Views -  then replace the Html.Object(Model) line with the required icon and label

Nov 1, 2011 at 2:18 PM

Thank you for the response, and adding it to the issue tracker.

Personally I have no immediate rush for this, so can wait until a subsequent release.