..:: Blog ::..

 ToolBook Blog Minimize

Jan 14

Written by: Tomas Lund
Monday, January 14, 2008 3:42 PM

Before we proceed you should take look at how it works, you might also want to download the source files (Dynamic HTML (v9).
 
In the sample zip file you will find a ToolBook file and a .js file containing one Javascript, the js file is linked into the toolBook file. For more information on linking external JaveScript files into ToolBook see this excellent article written by Denny Dedmore of Sumtotal.
 
Lets look at the .js file first:
 
The .js file contains one function which does all the heavy lifting in the sample, so lets take a look at it.
 
function tbfunction_SetObjectHTMLText(obrefName,htmtxt) {
                var objRef = TBK.Persistence.dereference(obrefName);
                objRef.setProperty("htmlText",htmtxt);
}
 
The function takes two parameters obrefName and htmtxt.
obrefName must be an ToolBook HTML object reference, the format looks like this p0.o0 (which translates to: the object with idnumber 0 on the page with Idnumber 0). So p2.o4 is the object with idnumber 4 on the page with Idnumber 2
htmtxt is the HTML we want to inject. This could be something like: <a href="www.toolbookconsulting.com">My website</a>
 
The next line
var objRef = TBK.Persistence.dereference(obrefName);
resolves the obrefName parameter as an object reference
 

the last line sets the htmlText of the object to the value of the htmtxt parameter.
objRef.setProperty("htmlText",htmtxt);

Now lets look at out ToolBook sample file:
 
Besides labels and headers the file contains 4 important objects:
  • field “html” – this is where you enter the HTML
  • field “HTMLOutPut” – this is where the HTML you enter above is rendered, note the field has no without border  so you cannot see it until HTML is injected into it
  • field “obRef” – a hidden field whichh contains the ToolBook HTML object reference to field “HTMLOutPut” – check out the SharedScript of the field for an example on why Openscript is still usesfull even if you are developing for HTML (beyond the scope of this article but I’ll cover that in a later post)
  • button “inject HTML” – this button have action editor code to call the JavaScript function in the JS file when its clicked. See the screen shots below for more details.
Use the execute Script  feature to call the external JavaScript Post
 Calling the JavaScript function using ExecuteScript
 
 
Edit the properties of the the execute Script  Feature to specify the parameters required by the function.
Parameters for the JavaScript function 
 
 
I hope you have enjoyed this article, drop me a comment if you have any comments or questions
 
Cheers
Tomas
 
 
IMPORTANT: This example require obfuscation to be turned off during HTML export in ToolBook.
If you don’t know what Obfuscation is the one minute explanation of what Obfuscation is comes here:  
 
Generally when code is obfuscated, human legible code is replaced with human illegible code, so a function called MySecretFunctionWithaLongName() might be reduced to _aF() when obfuscated.
This has two purposes, the code is more difficult to hack figure out hence more secure, and the filesize of scripts is reduced improving performance of the code.
 
Those with appetetite for more info on obfuscation check out http://en.wikipedia.org/wiki/Obfuscated_code
 
Note while It is possible to achieve the same with obfuscation turned on but as the code is illegible for humans it proves very bad as a sample.

Tags:

2 comments so far...

Re: Dynamic HTML: HTML tables in ToolBook

Hi Tomas,

This is great stuff!
Please explain, what TBK.Persistence... is

By Jørgen Nielsen on   Wednesday, January 09, 2008 3:30 PM

Re: Dynamic HTML: HTML tables in ToolBook

Thanks Jørgen

According to Tim Barham the persistence engine is what remembers state when you leave a page and to support it , you should always use setProperty() rather than setting the property directly.

hope this is helpful
Tomas
"()"

By TomasLund on   Thursday, January 10, 2008 11:59 PM

Your name:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment    Cancel  

  
 Search Minimize


  
 Quick links Minimize


  
 Blog List Minimize


 Print   


Copyright 2007 by ToolBookConsulting.com   Terms Of Use  Privacy Statement