OS 11: how to ask a webblock for data?

Hi,

I need to use a scenario like this:

  • there is a web screen and a webblock on this screen
  • this webblock gathers some input from the user
  • there is also a button on the screen that is to store data, entered by the user, somewhere - e.g. in some database

I don't want to constantly send entered data to the screen, using Input's OnChange event. Let's assume that these data are not validated - using OnChange would produce unnecessary net traffic. Therefore I need to be able to explicitly ask the webblock for the user's data.

It was easy in OS 10: 

  • I add a parameter to the webblock (text, "Command")
  • the screen's button sets this parameter to "Get Data" and refreshes the webblock
  • in Preparation of the webblock I detect this value of Command and do nothing else than packaging all the data to a string (any way) and sending it to the screen using Notify action

It works perfectly and synchronously (refresh webblock -> get its data -> refresh another webblock -> get its data -> store all to the database; all this as a sequence in a single button's handler).

Now the Notify action is deprecated so I don't want to use it. I should use Events instead of Notify. But - I can't use Event in Preparation: I'm not allowed, I can't drop an Event on Preparation.

I've found a hint. how to invoke a webblock's event from a screen:

  • put a hidden button on the webblock, mark it with a dedicated CSS class
  • in the screen button's handler run some JavaScript that "clicks" (using jQuery) this hidden button
  • in the handler of this button raise the required Event

OK, it works. But with some difference: it is asynchronous. I mean that the handler of the screen button must end before the webbloks button is clicked. And this makes this technique in my scenario useless.

Any idea?

Regards

Tomasz


Hi,

I think I don't like this approach, but it works...
See the attached OML.

Cheers.

Hi,

Thanks but it is still asynchronous. The "Ask data" handler must end before the screen gets the webblock's data. So the problem remains unsolved.

Regards

Tomasz.

Hi,

Why not store that data on a session variable? It would sort of work the same way the notify works, you would be storing a single string into a variable. I'm not sure its ideal, but it might be better then using js and an hidden button to do the trick.

Regards,
Jose

Thomasz,

You can move the logic required to process the data from the web block to the Event Handler.

So, what is the problem of being asynchronous? Could you provide some light on this requirement?

Cheers.

Hi,

@Jose: when using session variables I would have to create many variables. Maintaining them would be painful. And look at use case when I have a dynamic set of WebBlocks on my screen... some nightmare.

@Eduardo: consider a button on the screen that is to store all the data to the database. Previously it was simple: get data from webblock1 -> get data from webblock2 -> store all to the database. All in a single screen action - a handler of this button's click. Now this handler can only fire requests to webblocks. And what about storing data? At the end of the last webblocks' event? Who can guarantee which would be the last one? Another nightmare.

Regards

Tomasz