This project is read-only.

Duplicate action names on the Find Menu throws an error

May 22, 2013 at 1:46 AM
Hi Guys,
           If multiple contributed Actions are found to set an object property of an object you get a crash as only 1 is allowed, maybe NO should just take the first one?
In GenericControllerImp
private ActionResult ActionAsFind(ObjectAndControlData controlData, FormCollection form)
INakedObjectAction targetAction = FrameworkHelper.GetActions(targetNakedObject).Single(a => a.Id == targetActionId);
May 22, 2013 at 8:11 AM
If multiple contributed Actions are found to set an object property of an object you get a crash as only 1 is allowed
Sorry - I don't understand what this is referring to. Please give example.

Also - per previous comment - when posting, please use the Code tags only for code - otherwise it makes it harder to read.
May 22, 2013 at 10:19 AM
I had two methods in my contributed repository.
public Practitioner GetNextPractitioner(WorkOffer workOffer)
public Practitioner GetNextPractitioner(string something)
And this caused the error, I was just testing, its not a problem for me.

Best Regards,
May 22, 2013 at 10:36 AM
OK, the point here is not having two finder actions that can return the same object - the principal problem is having overloaded actions (i.e. two or more actions with the same name but different params). It would be fine to have:
public Practitioner GetNextPractitionerByName(string name) {}

public Practitioner GetNextPractitionerByNumber(int number) {}
N.B. This is in the manual:
8.6. Unexpected behaviour in the user interface
This section contains suggestions on what to look for if your application is not behaving as you expect at the user interface.

A public method is not appearing as an object action
Possible causes:

Naked Objects does not recognise any overloaded methods as actions. (This is because the various overloaded versions would show up on the menu with the same label.)
Also - I think that overloaded actions are logged as a warning in the log file, if logging is used.

You wrote: maybe NO should just take the first one?

The only effect of that would be to generate different postings asking why the second one hasn't appeared ;-)

There is a further issue with your example, though: a finder action can't take a reference object as a param, so:
public Practitioner GetNextPractitioner(WorkOffer workOffer)
wouldn't appear as a finder action, even if it wasn't overloaded. See
May 22, 2013 at 12:19 PM
Daer Richard,
                  Sorry yes I rad the doco before, I was just wondering if the system should crash as it did? Do you raise errors when something is coded incorrectly?
May 22, 2013 at 2:41 PM
I tried it out. It did not 'crash' on me, but did generate an error message 'Sequence contains more than one matching element'. It should not do this. Two finder menu actions with the same name should result in those actions being greyed out and disabled with the tooltip 'Duplicate Name' - as is the case for two regular actions, or two contributed actions. I will raise a ticket for that.
May 22, 2013 at 10:55 PM
Sorry yes I should have said what the error was. I didn't know that you could disable actions and I didn't know that you supported tool tips.
Totally awesome stuff! That is excellent degradation behaviour!

Best Regards,