Disable on Action method, parameter is null

Dec 6, 2012 at 2:40 PM


I have a contributed Action declared as:


public SomeObject AddAllowance(IClaim claim, ICustomer customer)


I have a Disable function which uses some simple logic against the claim object to decide whether the action should be enabled or disabled.


public string DisableAddAllowance(IClaim claim, ICustomer customer)

   if (((Claim)claim).CurrentStatus != ClaimStatus.PENDING || ((Claim)claim).CurrentStatus != ClaimStatus.AWARDED)
                return "You are not allowed to Add Allowance because the current status of the claim is not PENDING";
            return null;

My problem is the in the Disable method, the claim is null and the method therefore fails with an null reference exception. 

Am I doing something wrong here?




Dec 6, 2012 at 4:05 PM

It doesn't really make sense to disable an action based on the parameters so the parameters are just there for signature matching.

In this case AddAllowance should probably be on the claim itself so that it is disabled unless the status is appropriate.

Dec 6, 2012 at 4:12 PM
Hmm... it could though, for contributed actions, because the framework already knows at least one of the parameter arguments... the object that is being contributed to.

This is an enhancement I've also been meaning to address in Isis "one of these days".

Dec 6, 2012 at 4:59 PM

This has been on the TODO list for a while ;-)  See http://nakedobjects.codeplex.com/workitem/61