Cant store listbox in property

I have a listbox in a web project that I populate multiple columns from a database and at the present time I am storing each row as a dictionary and then if their are no new records I simply populate said listbox from the dictionary rather than pull all the data back from the sql server. This works great but I then started to think that a quicker way (as it would need less processing) would be to have a session property of type WebListBox which I have created called “currentListboxContent” and after I populate the listbox for the first time I add the following line of code (where myListbox is the name of the actual listbox)

session.currentListboxContent  = myListbox

Then when the page is loaded again I do some check to see if anything has changed and if not I do the following in the open event for the myListbox.

myListbox = session.currentListboxContent

Sadly the listbox does not get populated, can anyone suggest why or what I am doing wrong.

Uh, no. And it wouldn’t be quicker behind the scenes anyway. All that data in the server app (your code) that needs to go into the displayed WebListBox needs to be sent from client to server. There’s no avoiding it.

I am not trying to avoid the stuff being sent to the client what I am trying to do is minimise the amount of work the server has to do to build the listbox each time as I am very aware that Xojo web apps have limitations when the server gets overloaded when the user number increases so by making it so that the server does not have to repopulate the listbox this should reduce the load as in effect by doing what I am trying to do it is only have to send it to the client rather than reprocess it.

I still can’t imagine how this would save any server side work under the hood. But, my imagination is not fully caffeinated yet today.

Mine is totally overloaded and screaming for a glass of wine, 3 minutes to go and it will be 5pm, wine time :wink:

Maybe I am trying optimize too much but it just seems pointless looping through the array adding rows to the listbox (which might have a few hundred rows) when you have already done it.

I dont really understand why you cans store the WebListbox in a WebListbox property as you can do this with other things (I think) so why not with the listbox? Actually whilst typing this I had a quick look at the framework.js for the listbox and can now see why it wont work and can also see that the load will be at the client side and not the server side as the server is passing the add row stuff to the javascript and the creation of the listbox is on the client and not the server which is what I was thinking.

That’s cheating :-). But it drives home the point.

Theoretically (*), you could create a Javascript that duplicates an existing WebListBox client side. BUT, it wouldn’t hook up with a server-side copy you could work with in your code.

(*) Mind-numbing exercise.

Nah, would need far too much wine to even begin to think about doing that!!! I am happy now that I know that most of the work is going on client side.