Page 1 of 1

HTML AREA Parsing

PostPosted: Thu Jun 10, 2010 1:15 pm
by Janssenjos
Hi all,
I was wondering if I could combine a call to a Servoy form function and a Javascript client function in 1 link:
(Following code goes into a HTML_AREA)

This code makes a link to a javascript function in the clients browser.
Code: Select all
<table>
<tr><td><a href=\"javascript:doClientFunction('-1')\"></td></tr>
</table>


This code makes a link to a servoy form function.
Code: Select all
<html><body>
<table>
<tr><td><a href=\"javascript:doServoyFunction('-1')\"></td></tr>
</table>
</body></html>


I'd need to combine both in one link (Is this possible?):
Code: Select all
<a href=\"doClientFunction();javascript:doServoyFunction('-1'); \">

I need this to show a loading text in the browser (client javascript call) and after that go to the servoy function.

Re: HTML AREA Parsing

PostPosted: Thu Jun 10, 2010 2:24 pm
by ROCLASI
Hi Jos,

I assume you are doing this in Webclient, because in Smartclient you can't use JavaScript inside an HTML_AREA field.
Anyway, have you tried to call the javascript:doServoyFunction('-1') from within the doClientFunction ?

Re: HTML AREA Parsing

PostPosted: Fri Jun 11, 2010 9:11 am
by Janssenjos
How to call a servoy function from within the client javascript?

If I knew how to do it, I would have tried :)

Re: HTML AREA Parsing

PostPosted: Fri Jun 11, 2010 9:34 am
by pbakker
The only way to call Servoy methods from within javascript in the browser when running the Servoy Web Client is by adding HTML with JavaScript links on your form, for example through a non-editable HTML Area. Servoy will recognize the method calls and will rewrite the call to become a wicket ajax call.

Paul

Re: HTML AREA Parsing

PostPosted: Fri Jun 11, 2010 10:05 am
by Janssenjos
Yes ok: thats like this:

Code: Select all
<html><body>
<table>
<tr><td><a href=\"javascript:doServoyFunction('-1')\"></td></tr>
</table>
</body></html>


But it isn't possible in code like this: ?
Code: Select all
<html>
<script type='text/javascript'>
function clientScript();
{
       //set loading text code
       .....
       //Call servoy function
       javascript:doServoyFunction('-1');
}
</script>
</html>



Cause in the link I click, i first want to do some client side functions, before going to servoy.

Re: HTML AREA Parsing

PostPosted: Fri Jun 11, 2010 10:18 am
by pbakker
No, that is not possible, but you could do something along the lines of this:
Code: Select all
<html>
<script type='text/javascript'>
function clientScript();
{
       //set loading text code
       .....
       //Call servoy function
       document.getElementById('dummy').click();
}
</script>
<input type="button" onclick="javascript:doServoyFunction('-1')" id="dummy"/>
<button onclick="clientSCript()">test</button>
</html>


The dummy input element can be hidden with some custom CSS.

Paul

Re: HTML AREA Parsing

PostPosted: Thu Jun 19, 2014 12:53 pm
by sergei.sheinin
I've used above method successfully. However it's not clear how to pass a parameter from the calling client side function.

Any suggestions?

Re: HTML AREA Parsing

PostPosted: Thu Jun 19, 2014 12:58 pm
by pbakker

Re: HTML AREA Parsing

PostPosted: Thu Jun 19, 2014 2:09 pm
by sergei.sheinin
That was easy.