function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Joey HoJoey Ho 

Does a MAP automatically update in VF page using a LIST?

Hi All, 

This is not a problem as such but rather something that I do not quite understand.
I have writted an apex and visualforce code that has operated correctly but I do not undertand why! Hope someone can clarify my misunderstanding?

I have a apex Controller class that has a inner custom wrapper class of objects that I called "AssetLine".

To make things simple, I used maps<string, AssetLine> where the key is the unique string name for each AssetLine.

Now I created a visualforce page which dumps out using <Apex:repeat> a LIST of AssetLine which obviously comes from the Map I created earlier. In this visualforce page contains inputText fields which allow me to manimulate the AssetLine individually and update the instance dynamically.

The ODD THING IS THIS: whenever I update the values in the inputText fields, these fields automatically update the corresponding Map<string, AssetLine> without me having to write any such code in the apex controller telling the LIST to update the corresponding AssetLine in the Map...

How is this possible that the MAP is automatically updated??!!!? 

Thanks.
Regards,
Joey Ho
Adnubis LLCAdnubis LLC
What you are doing is binding your AssetLine object properties to the inputText fields on your visualforce page. It is indeed make changes directly to the AssetLine object that would then be accessible within your controller. 
Joey HoJoey Ho
Thanks for your help.

The thing still gets me is that although I am using a LIST<AssetLine> to dump out in a <apex:repeat> tag, I still don't see how the map<string, AssetLine> knows which AssetLine was altered. I am guessing that the LIST<AssetLine> references the same "memory" address as the map? Cheers.