This project is read-only.

Plural name not used on table headers

Oct 15, 2011 at 11:14 PM

I noticed that specifying a [Plural("...")] attribute on a class does not result in it being used in the display of a column header of a collection of that type in a table.

Eg. when using Html.CollectionTable...() methods.

I thought I'd jump into the deep end of the code to see if I could make it do that.

I tracked it down to where "Name" is being selected off an IEnumerable of INakedObjectAssociation in the NakedObjects.Mvc project, line 1452 in CommonHtmlHelper.cs.

However, I could not find how to obtain the INakedObjectSpecification of the entity collection property from the INakedObjectAssociation that was available in order to access it's  PluralName property. Perhaps it isn't possible in that context. I am not sure; first time swimming in this code. :) Any thoughts?

However, I ran into a problem getting the projects compiled.

While trying to build the Framework solution, I got the following:

"Unable to find version '4.0.0.0' of package 'NakedObjects.ProgrammingModel'.    NakedObjects.Architecture"

The ProgrammingModel solution built fine. But I was unable to find a dll to reference by that name in the bin folder of the Programming Model project.

And of course the MVC solution gave this:

"Unable to find version '4.0.0.0' of package 'NakedObjects.Framework'.    NakedObjects.Mvc.App"

How do I get the various references setup between the solutions / projects?

Oct 17, 2011 at 9:12 AM

You saythat a [Plural] attribute on a class does not result in it being used in the display of a column header of a collection of that type in a table.  But I think this is correct behaviour:  the column name for a collection in a table is based on the name of the collection property (just as for columns representing other properties), not the type in the collection.  (Of course, it is quite common for developers to make the name of the collection be the hand-pluralised version of the type name, but that is coincidental).  If you want to change that column header, you need to change the name of the collection property, either directly or using [DisplayName] on the collection property.

However, [Plural] (as applied to the type that's in the collection) should be picked up within the body of the table, where you see the number of elements of that type being displayed, and I just checked that this is indeed the case.

In regard to the difficulty of compiling the framework, we are preparing some notes about how to build the framework.  We'll post them here, soon, and as a .txt file within future releases.

Oct 17, 2011 at 9:24 AM

>But I think this is correct behaviour: the column name for a collection in a table is based on the name of the collection property (just as for columns representing other properties), not the type in the collection.

You are absolutely correct. I was being brain dead!

>However, [Plural] (as applied to the type that's in the collection) should be picked up within the body of the table, whereyou see the number of elements of that type being displayed, and I just checked that this is indeed the case.

Yes, this has always worked correctly.