Getting page object values
Posted
#1
(In Topic #874)
Banned
For example my form has a WebAudio object.
I want to read/write the DOM property .currentTime
So from my gambas cgi web app i need to do something like this…
Only there is no GetValue command.
Posted
Banned
(Note: these are initial findings that i could be wrong about)
There must be 2 parts to a gambas web page, the gambas part and a .js file with your functions in it (if you want fancy functions).
When the gambas application runs on the server it basically converts itself into a bunch of javascript functions.
All the gambas type WebButton1_Click() events and the like become javascript functions from the lib.js file of gb.web.gui.
Forget that quote, i was wrong (see later post)This ALL happens on load and all the client browser receives is the output html/javascript code.
Any other functionality needed after page load HAS to happen in your .js file. (make a file like myfunctions.js and place it in project dir)
this requires working out how Javascript works too (luckily i have some experience)
Examining the code of the lib.js file from gb.web.gui and the code of the controls is a great way to learn what's happening and doing the same.
So I CAN get object values and work with them but only if i do it in my own custom.js file.
The bad thing is that errors in the js file are not so easy to find. using firefox or chrome browsers dev tools can help a lot.
Posted
Banned
Within my WebAudio.class I used something like the following…
Code (gambas)
- $fPosition = Pos
- Print "></audio>";
Now in my WebForm i can use the following event…
Doing this seems to work really well for various things.
i have a readable time position now in the WebAudio and also in the webform.
Hoping that'll help someone…
BruceS
Posted
Banned
firstly a problem with using an event handler the way i was…
Benoit Minisini said
Note that you have a WebControl '_GetUpdateJS()' method that generates
for you the HTML code that calls 'gw.update' when a specific DOM event
is triggered.
So scrap that idea for that purpose as it was causing all my objects to refresh/flicker.
Benoit Minisini said
You must send the 'Position' property from the browser to the server by
using:
gw.update(<id>, '<property>', <value>);
Where <id> is the id of the control, <property> the name of the
property, and <value> its value.
Then you handle that message on the server in the '_UpdateProperty'
hidden method of the control.
So this method works briliantly…
Code (gambas)
No more flickering.
the ontimeupdate event auto-sets $fPosition and raises the Position event.
One more quote from Benoit as it's important need-to-know stuff…
Benoit Minisini said
When a property of a control changes, you usually must refresh it by
calling the _Refresh() method.
You can avoid a full refresh of the control to speed up things by using
custom javascript code instead. Look at the SetText() method of the
WebTextBox control to see an example.
Another point: you must not catch an event on the browser side if you
don't implement the event handler on the server side.
To detect that, use the 'Object.CanRaise()' method. As usual, look at
the '_Render' method of WebTextBox for an example.
Many thanks to Benoit for his help and hopefully this can help you too.
Bruce
1 guest and 0 members have just viewed this.





