Ajax update on list box leaves ListBox.List.Count=0

Ajax update on list box leaves ListBox.List.Count=0

  

When I add or remove from the items underlying the list box, I do a data refresh on the items, and then an ajax-refresh on the list box.

The list box shows the new list correctly, but when I try to loop on the ListBox.List it fails.  Debugging shows that the ListBox.List.Count field is 0 even though I have a number of elements displaying correcly on the screen ???

I tried doing the ajax-refresh on the container of the ListBox but I get the same result.

Reloading the screen however correctly resets the ListBox.List.

What am I doing wrong?

Jeffrey Kesselman wrote:

When I add or remove from the items underlying the list box, I do a data refresh on the items, and then an ajax-refresh on the list box.

The list box shows the new list correctly, but when I try to loop on the ListBox.List it fails.  Debugging shows that the ListBox.List.Count field is 0 even though I have a number of elements displaying correcly on the screen ???

I tried doing the ajax-refresh on the container of the ListBox but I get the same result.

Reloading the screen however correctly resets the ListBox.List.

What am I doing wrong?

Jeffrey,

Look my example if I understando your problem.

I loaded the listbox from my Aggregate and I manipulated the data whatever I want .

Is That your problem?

LISTBOX EXAMPLE



No thats not the problem.

The displayt updates fine.  But the underlying List attribute does not reflect what is displayed.

I will post an oml for you to look at that illustrates the proiblem.

Okay in the attached oml login as user "uff"  password "Password"
Select character "durber"

Note that there is a list of items added already to durber.  Click on them in turn and see that the
proper Item ID is reported for each.

Now click "add" and add an item.  Note that when you return to the main screen the new item IS in the list.

Click on each item.  Note that you do NOT get the proper ID anymore but the same, wrong id for every item.

Now refresh the screen, and click on the items.  Note that now the items report their item IDs properly.

In the debugger, I see that, when you have returned from the Add dialog, the ItemListBox.List.Length is 0, which is definitely wrong and I assume what is causing the IDs to not be found.


Some more info.  After update ItemListBox.List.EMpty = true, even though the display of the list box shows many entries.

This is my listbox update code that causes this effect...

I found a work around,m though it still loosk like a bug.

Doing an ajax refresh on the whole page container resets the ListBox properly.

Spoke too soon.  Updating the entire page doesnt update the listbox at all, which is why it still functions :/

Jeffrey Kesselman wrote:

Spoke too soon.  Updating the entire page doesnt update the listbox at all, which is why it still functions :/

Jeffrey,

Look if that you want. I made some changes in your logic and how load the list. And now all selections works  well.

An TIP .. remember that List Data type can´t hold in viewstate. You need to use an RecordList. Ok?






Solution

César Mateus wrote:

Jeffrey Kesselman wrote:

Spoke too soon.  Updating the entire page doesnt update the listbox at all, which is why it still functions :/

Jeffrey,

Look if that you want. I made some changes in your logic and how load the list. And now all selections works  well.

An TIP .. remember that List Data type can´t hold in viewstate. You need to use an RecordList. Ok?






Forgot the OML ... sorry ... lol




Solution

César Mateus wrote:

César Mateus wrote:

Jeffrey Kesselman wrote:

Spoke too soon.  Updating the entire page doesnt update the listbox at all, which is why it still functions :/

Jeffrey,

Look if that you want. I made some changes in your logic and how load the list. And now all selections works  well.

An TIP .. remember that List Data type can´t hold in viewstate. You need to use an RecordList. Ok?






Forgot the OML ... sorry ... lol




You can test in my environment .. ADD ITEM works properly ... 

https://cmateustech.outsystemscloud.com/ALTraders



Thanks very much.,  I hacked around this problem by forcing  a page reload  but it sounds like your solution is more elegent and correct.


César Mateus wrote:

César Mateus wrote:

César Mateus wrote:

Jeffrey Kesselman wrote:

Spoke too soon.  Updating the entire page doesnt update the listbox at all, which is why it still functions :/

Jeffrey,

Look if that you want. I made some changes in your logic and how load the list. And now all selections works  well.

An TIP .. remember that List Data type can´t hold in viewstate. You need to use an RecordList. Ok?






Forgot the OML ... sorry ... lol




You can test in my environment .. ADD ITEM works properly ... 

https://cmateustech.outsystemscloud.com/ALTraders





Jeffrey Kesselman wrote:

Thanks very much.,  I hacked around this problem by forcing  a page reload  but it sounds like your solution is more elegent and correct.


César Mateus wrote:

César Mateus wrote:

César Mateus wrote:

Jeffrey Kesselman wrote:

Spoke too soon.  Updating the entire page doesnt update the listbox at all, which is why it still functions :/

Jeffrey,

Look if that you want. I made some changes in your logic and how load the list. And now all selections works  well.

An TIP .. remember that List Data type can´t hold in viewstate. You need to use an RecordList. Ok?






Forgot the OML ... sorry ... lol




You can test in my environment .. ADD ITEM works properly ... 

https://cmateustech.outsystemscloud.com/ALTraders





That´s great! Glady to help you out ...  Did you see the OML? 


César Mateus wrote:

Jeffrey Kesselman wrote:

Thanks very much.,  I hacked around this problem by forcing  a page reload  but it sounds like your solution is more elegent and correct.


César Mateus wrote:

César Mateus wrote:

César Mateus wrote:

Jeffrey Kesselman wrote:

Spoke too soon.  Updating the entire page doesnt update the listbox at all, which is why it still functions :/

Jeffrey,

Look if that you want. I made some changes in your logic and how load the list. And now all selections works  well.

An TIP .. remember that List Data type can´t hold in viewstate. You need to use an RecordList. Ok?






Forgot the OML ... sorry ... lol




You can test in my environment .. ADD ITEM works properly ... 

https://cmateustech.outsystemscloud.com/ALTraders





That´s great! Glady to help you out ...  Did you see the OML? 


No, but understanding that the ListBox needs to be backed by a seperate record list now, Im sure I can recreate it.


Oh, There's the oml!  I have it now, rhanks!