I have checked that 'temp' carries the correct value. However, no matter which method I use to set the variable it doesn't seem to stick. When I call the validate() function the value is NULL even though it has been set before.
The validate() function just some some validation on the variable 'suppliedInput'
Any ideas would be greatly appreciated.
Robin Heard wrote:Some simple length checking on the value that is set previously:
However, when the method is run the value is NULL.
What value is null?
Show the entire method body, and signature.
Put in print statements to show i, additionalDetailValidations.get(i), and additionalDetailValidations.get(i).additionalDetailValidationValue).
It's very hard to debug something that's shown in incomplete pieces, rather than an SSCCE.
The 'order' object is the same for both. Could it be to do with the fact that getAllItems() returns an array and then getAdditionalRequirementsType() also returns an array and I'm setting a value within that. It seems like the 'order' object isn't holding the variable the next time it is accessed.
Could it be to do with the fact that getAllItems() returns an array and then getAdditionalRequirementsType() also returns an array and I'm setting a value within that
They can't be returning arrays or you would have  to access an element in the array, I guess they are returning ArrayLists.
Add the following line to the line directly after the one where you set suppliedInput = temp and tell us what the output is.
[Server:server-one] 05:39:10,424 INFO [stdout] (http--0.0.0.0-80-5) Retrieving request parameter for 0: 123456789123456789123211231
[Server:server-one] 05:39:10,454 INFO [stdout] (http--0.0.0.0-80-5) In: 123456789123456789123211231
[Server:server-one] 05:39:10,455 INFO [stdout] (http--0.0.0.0-80-5) Out: 123456789123456789123211231
[Server:server-one] 05:39:10,528 INFO [stdout] (http--0.0.0.0-80-5) temp = 123456789123456789123211231, supplied Input 0 = null
[Server:server-one] 05:39:10,572 INFO [stdout] (http--0.0.0.0-80-5) Is: null but should: 20
You create new AdditionalDetail instances - i.e. each time order.getAllItems().get(i).getAdditionalRequirementsType(order.getrequestType()).get(t) gets called, given the same order, i, and t a new and unique AdditionalDetail object is created (probably a whole new list of them) and the created objects are never stored or reused. So each time you call that method the suppliedInput would be completely different. But that is a guess because you never do what Jeff asks you to do.