Servoy 5.1.1 ServoyBrowser bean question

When using a htmlarea on a form the code below runs the getRelations method when clicked on the link in the htmlarea, but in the ServoyBrowser bean doesn’t do anything with it. Is there a way to get this running in the bean?

$html += '<tr><td class="td" border=0><a STYLE="text-decoration: none;" href=\"javascript:getRelations(\'' + $cust + '\')\">'+ $name + '</td></tr>';

Regards,
Peter

Hi Peter,

You are escaping the double quotes wich is not necessery. Also when you use CSS in HTML and you define a styleclass that matches a HTML tag (in your case TD) then you don’t have to add a ‘class=“td”’ because it already knows that it should apply it to this tag. Also you can add a ‘A’ style to let it apply to all A tags. This way you don’t have to add inline CSS code.

So your code can look like this:

$html      = '<html><head><style>';
$html      += 'td { /* your td style goes here */ }';
$html      += 'a { text-decoration: none; }';
$html      += '</style></head><body>';

// your table code starts here....

$html      += '<tr><td border=0><a href="javascript:getRelations(\'' + $cust + '\')">'+ $name + '</td></tr>';

// end of your HTML code
$html      += '</body></html>';

Hope this helps.

Hi Peter,

in the ServoyBrowser bean, you don’t use “javascript:getRelations()” inline.
But there are 3 ways you can do what you want:

1/ Use a special protocol “command”:
so if you use the code Robert’s code, you will still need to change “javascript:getRelations(…)” to <a href=“command://getRelations?”+$cust+">…

2/ Use a special function “sendNSCommand”:
this time you will write <a href="javascript:sendNSCommand('getRelations','‘+$cust+’')>

3/ You can add a getRelations() javascript function inside your html:

<script type="text/javascript">
function getRelations(what) {
    sendNSCommand("getRelations",what);
}
</script>

and then call it as is: “javascript:getRelations(…)”

I would also recommand prefixing the “getRelations” method with the name of the form if the “getRelations” is a form method, like this :“formName.getRelations”, and with “globals” if it is a globals method, like this: “globals.getRelations”.

Check the “Integrated” example in the browser suite sample solution (look at the html source of the example).
Also check the section 5.4 of the PDF doc (page 29) that explains this.

Hope this help,

@Robert, thanks for your comment on the style class.

@Patrick,

Also check the section 5.4 of the PDF doc (page 29) that explains this.

I missed that one, it’s working now :D.

I thank you both for the swift reply.

Regards,

Peter

Hi Peter,

I almost forgot (apart from the different behavior of the browser suite bean).

Peter de Groot:

<td class="td" border=0>

Border is not a property of the td tag. That would be for the whole table and therefor it’s a table tag.

Hope this helps.