Web Dialog how to implement correctly 2023R3

Hello all,

In the middle of a method, I need to ask the user a question. Depending on the answer, the code needs to execute one way or another.

In API1, a complex coding had to be created usually involving a timer. Is API2 the same? I looked at the help and the samples, but none of them really appeared to do what I need - or maybe I missed something?

Can anyone please advise the correct way to fill my need? Sample code? Ideas?

Thank you,
Tim

Have you checked out these example files?

Hi William Reynolds

Yes I have.
It does not show how to program it for my use - a question in the middle of a method.

Tim

Ah, I think I understand now - you want to halt code flow mid-method. I think that web app dialogs (unlike desktop) don’t interrupt executing code. Offhand it seems like you’d need a series of distinct methods that all end with a dialog, and that dialog triggers a subsequent method to evaluate the users input.

1 Like

everything in web is asynchronous. so when you show the dialog, the event loop goes on
and the app doesn’t wait for a user input
you have to implement a sort of state machine with properties in the page that calls the dialog
when the user clic in the dialog a button for example, the state properties goes one state up

1 Like

I put a quick app together to show one approach (posted here). The concept is that each Question dialog calls a ‘review’ method and passes itself into the method to get evaluated and then triggers a method based on the selection. I used an array in the dialog assuming you may have more than one answer and may want to examine multiple answers. It’s very rough but might offer some differing perspectives.

2 Likes

Tim, in the application I am converting from Xojo2018 to Xojo2023r3 I have similar situation. The ListPage (web page) has control with the name LateReasonDialog1 (this is the Message Dialog project item dropped onto the page, shows at the bottom, the Super is changed from Web Dialog to the name of the custom page LateReasonDialog of type WebDialog). The LateReasonDialog1 control has event handler Dismissed, the code behind it has if statement that either updates database or does nothing, at the end it calls custom method LateReasonDialog1.OnDismissed (this is the method on the custom LateReasonDialog web dialog that does some cleanup).
The LateReasonDialog has few controls that show the record from the database, has the field to edit/enter some text and two buttons (Cancel and Save), both buttons essentially have the same code that is Close. Note, the ListPage invokes LateReasonDialog.Show then sets some properties and then calls custom Init method, that is it.

As you see from above, the actual code doing the saving occurs in MyPage.LateReasonDialog1.Dismissed method.

Fyi, my understanding: In Xojo2018 the web dialog is instanciated only once upon instanciating MyPage. In Xojo2023r3 the web dialog is instanciated every time the Show method is invoked. This means that the web dialog properties must be set after invoking Show, not before.

I am not sure if I have explained this in clear way, but if you find it useful and need more info please don’t hesitate and ask.

Thank you all for your responses!
@Jean-Yves_Pochez - Are all web applications, regardless of =/language used, asynchronous?

@William_Reynolds - thank you for the sample! That streamlines it for me. I think before I had used timers, but that was a bit of a PIA.

@Grzegorz_Greg_Pasternak - Thank you for your insight.

In Xojo2023r3 the web dialog is instanciated every time the Show method is invoked. This means that the web dialog properties must be set after invoking Show, not before.

That is interesting -

Appreciate the tips everyone!
Tim

I don’t know for others… but xojo web does