Trigger other behavior when modifying a reference type property using modify method

Dec 13, 2012 at 9:51 PM

I have a scenario like this: when a claim is created for a customer, user can pick up the customer by using the 'Find' button. Before user clicking save button to save the claim, he wants to select a different customer. When he clicks 'Find' button and select 'Find by Id', enter id, and click 'OK'. The user can see the customer just selected appeared on the screen, however when he clicks 'Save' button to save the claim, the original customer is saved.

I create a method called ModifyClaimant like below


 public void ModifyClaimant(ICustomer newClaimant)       {                    

 _claimant = newClaimant;           

Claimant_Id = newClaimant.Id;       

//Do other logic, for example modify the Title when different selected                                        


I put a breakpoint to see when it jumps into this method. It seems to me when 'Find' button is clicked, before the user enters customer id, it will jump into this method. When user enter customer id, click ok, it will jump into this method again. Check newClaimant value, it always has original customer value, not the one just picked up. When save button is clicked, it will jump into this method again, now newClaimant has the customer which was just selected. However, after save button clicked, new customer value is not saved. Instead of , the original one is saved.

Am I doing something wrong here by using modify method suggested by NOF? Basically, what I want to do is when the customer associated with a claim is changed, the title on the screen should be updated to the new customer which is just selected. And after save button clicked, the new customer should be saved with this claim. 


Dec 14, 2012 at 2:26 PM

Can you clarify a couple of things please, Xiao:

1. Is the object on which you are working (i.e. changing the Claimant) Transient, or is it an already-persisted object being edited?

2.  If the object is transient, how has the existing Claimant (which you want the user to be able to change) been set up?

3.  Is that existing Claimant a 'default', that the user is encouraged to review and change?  (That just seems rather unusual to me).


Dec 16, 2012 at 10:19 AM

Thanks Richard.

For question 1, the object (i.e. Claim object) I'm working on is in its transient state. I set the initial Claimant value in the dialog screen first, then I want to change Claimant value using 'Find' button on another screen which is Claim screen before save it. It seems to me I should not do that.


For question 2, I mentioned on the above, the existing claimant is set up on another dialog screen (I.e. on Create Claim dialog screen, which you can pick up scheme code and claimant  


For question 3, after talked to my colleague, I think I should not allow user to change Claimant when it's on Claim screen. The user should do that on dialog screen.