Problems to add and refresh rows in a web listbox

Happy new year everybody,

I am trying to do a webapp in xojo but I have some problems to add new rows in a listbox and then refresh the listbox to show the new added rows.

This problem is easy to resolve in standard webapps but in my sample I have a webpage from which I call to different webcontainers that are created in runtime and they are showed. I need this web structure but I cannot to do two things:

  • Add new rows (customers) if after I don’t click the refresh button.
  • If I move between different webcontainers, I lose the information added in the listbox when I come back again to this.

I attach an example here: https://xojo.io/529d5db2cffc

Could anyone help me?

Thank you very much.
Sergio

in the add button mouse down event , before show add this line

AddHandler RequestsPage.ShowNewSampleDialog.dismissed,WeakAddressOf dismissed

so your addButton code will be:

[code] //Show web dialog to add a new customer
AddHandler RequestsPage.ShowNewSampleDialog.dismissed,WeakAddressOf dismissed
RequestsPage.ShowNewSampleDialog.Show

//Refresh webpage
//RequestsPage.Show //No need to reshow[/code]

add to the CreateRequestControl2 container this method:

Sub Dismissed(d as NewSampleDialog) if d.SampleValues.Ubound>-1 then //There is data to add AddCustomerList end if RemoveHandler d.dismissed,WeakAddressOf Dismissed //remove the handler!!! End Sub

Now it will work

Hi Antonio,

thank you so much for your code. I have updated the example and now it works. You have resolved my first problem (add rows to the listbox) but if I move with the arrow to the next webcontainer when I return to the previous container, the listbox is empty. If I click on refresh button I get the rows added. Could you help me again?

A lot of thanks Antonio, I’ve been locked at that points several days.
Sergio

This is due by a bad design :frowning:
The New sampleDialog should be used to insert/edit new data, not a repository.
My solution is a suggestion on how to implement this, but you should add the data to a db or a main container property. Otherwise, since you create a new editor every time (Shown event) then you loose your data. If you press reload then your code will reload the last data you edit, but in the long run this will be wrong.

So you have to change your design. Is ok to close end create the editors (in order to avoid to fill the browser memory) but you must design some place where you keep your data.

Thanks Antonio for your suggestion,

I’m sorry because I don’t show you my complete webapp. In this one, I store all the data from the listbox and from the other webcontainers in a sqlite database but I had the doubt of how to store all that information: in my first option, the user should fill all the required fields in the whole of webcontainers and then transfer all the data into the database; in the second option, the filled fields in each webcontainer are stored into the database as the user moves along the webcontainers. I didn’t choose the second option because the user could cancel all the registration process and then I needed to delete all the transferred information into the database and I preferred to do the least number of transfers to the database.

For your suggestion, I think that the best option is the second one, isn’t it?.

Sergio