Ajax Refresh appends results

Ajax Refresh appends results

  

Hello guys, 

I have a page with several web blocks where i use lists of points as a input parameter for those web blocks.

Those blocks are visible only when a dropdown value is selected, turning the visible os them to true or false. To do this i'm using a Ajax submit with Ajax refrehs of the containers.

The problem i have is that when i make that Ajax refresh it duplicates all of my values on the list.

I'm putting those value on the preparation.


Can you help me with that?


Cheers,

NM

Hi Nelson,

You should use a ListClear when overwriting values in a list.

This is necessary because Lists are passed as a reference and not as a value. This means that when you use a list as an input parameter and you change that parameter, you are changing the original list, as they are pointing to the same object.

As a rule of thumb, it is better to use ListClear to make sure that the List is indeed empty, in order to avoid duplicate values.

Cheers,

João

João Mateus wrote:

Hi Nelson,

You should use a ListClear when overwriting values in a list.

This is necessary because Lists are passed as a reference and not as a value. This means that when you use a list as an input parameter and you change that parameter, you are changing the original list, as they are pointing to the same object.

As a rule of thumb, it is better to use ListClear to make sure that the List is indeed empty, in order to avoid duplicate values.

Cheers,

João


I'm not overwriting, in fact im not doint nothing to those lists after the preparation.

I only switch a variable that is true or false to show those lists.

Why it's duplicating?

Cheers,

Nelson

Hi Nelson,

If you are only filling the list in the preparation, and not changing the lists inside the web blocks, try calling ListClear on the list before appending the values.

I have had this problem before when appending values to a list in the preparation, and, by doing this, it was solved.

This might happen because Lists behave differently to other variables and are not reinitialized when rerunning a preparation. In my case, I had a button with Submit and when the preparation was run a second time the list remained with its previous values, and, by appending the new values, they appeared to be duplicated.

Regards,

João