Hi,
Hope someone can help with this:
In chapter 13 Validation and Data Binding in Spring MVC, in example ch13-bankapp if I run the following test:
1. see the list of deposits
2. Click "Create New Fixed Deposit"
3. Enter deposit details and click "Save"
then I get the following console messages:
A - getNewFixedDepositDetails() method: Returning a new instance of FixedDepositDetails
B- openFixedDeposit() method: Fixed deposit details successfully saved. Redirecting to show the list of fixed deposits
... 2 more messages
Console messages A and B show that on clicking "Save", the getNewFixedDepositDetails() method populates an object called "newFixedDepositDetails" into the Model object, and then immediately afterwards the openFixedDeposit() method runs and
uses the @ModelAttribute argument annotation to get the "newFixedDepositDetails" object from the Model and put it into an object called fixedDepositDetails.
Question: why doesn't the "newFixedDepositDetails" object retrieved from the Model by openFixedDeposit() contain the dummy data "newFixedDepositDetails" created by the previously called getNewFixedDepositDetails() ?
I would imagine that when you click "Save", the browser returns data to the server, and the instance of "newFixedDepositDetails" Model attribute that contains user-entered data is overwritten by "newFixedDepositDetails" written by getNewFixedDepositDetails() ?
Clearly the software works as intended, so I have to assume that getNewFixedDepositDetails() does not write "newFixedDepositDetails" to the Model if the Model already contains an attribute called "newFixedDepositDetails". Is this correct?
Thank you.