JS

Q:
I have a javascript variable in my webview section by the name of “message”. This variable has a string. How do I assign this value to one of my VFP variables?
A:
Strings can be delimited with double-quotes “”, single quotes ”, or square brackets []. This allows you to have quotes within quotes.

Code:
Lianja.execute("VFPVariable  = '" + message + "'");

and

Code:
Lianja.execute("VFPVariable  = ''");

Q:
to include a (local) js file in my .jssp page. I have a file by the name of GpsGate.js in my app and it’s under “Javascript Files”. How and where do I include this file in the .jssp file?
A:
If the js file is in the App’s directory (which it is if it’s listing it under ‘Javascript Files’ in the Apps Workspace) you don’t need to include the path on the file name


JavaScript has access to the Lianja system object and its methods: Lianja.getelementbyid(), Lianja.evaluate(), Lianja.execute() etc.If it’s JavaScript within an rsp script or html page, rather than a js script, call getelementbyid() using evaluate()/execute(), e.g.

Code:
Lianja.execute('Lianja.getelementbyid("page1.section1").caption = "New Caption"');        
m_section = Lianja.evaluate('Lianja.getelementbyid("page1.section1").caption');        
Lianja.showMessage(m_section);

Q:
I want to create a calendar section using the web client. There are no button to click to add the delegate
A:
you need to create a javascript custom library for this app (as its a web app) and then just type in the name of the click delegate. This will be called with one argument which is an object containing properties for the cell clicked in the calendar.

Screen Shot 2015-01-28 at 2.33.06 PM.jpg

Screen Shot 2015-01-28 at 2.33.30 PM.jpg


Q:
otool.addObject(page1);
A:
In JavaScript you must use the standard addObject(name, classname) call.


It seems the names of the objects need to be lowercase not mixed case.


Don’t forget semi colons.Also – add the curly brackets in the JavaScript function. If you don’t, you may have a problem when you reload the app.


In dynamic server side javascript pages (.jssp pages) you don’t need to use Lianja.getCursor() as you have total control of the Recordset.


Q:
Is it possible to reference a textbox in a JavaScript canvas section when called with showDialog()?I know the click event on the button is working via a messagebox() and the code is in the library lib:/lib_dlgJSCanvas1_section1.js.
A:
How are you calling Lianja.showDialog()?Yes you can reference the UI control directly after addObject() just as you would in VFP.e.g.dlg_textBox.text = “Hello world”;Open the web inspector by right clicking and in the console type window.dlg_textBox to verify the name is correct.The Web Client does not currently handle UI page library pages with Lianja.showDialog() or Lianja.showDialogPanel().You need to use either a .rsp page, a .jssp page or a javascript function e.g “createMyCanvas()” to populate the dialog contents.Also messageBox() is non blocking in the Web Client. You have to use callbacks with a JavasCript function closure to handle the “Ok” “Cancel” buttons.For a blocking messagebox() you can use confirm() in JavaScript.

Code:
var r = confirm("Are you sure you want to continue?");
if (r) {    Lianja.writeOutput("You pressed OK!");} 
else {Lianja.writeOutput("You pressed Cancel!");}

And for an inputBox() you can use prompt(). The trouble with all these is that they have a “JavaScript” title which cannot be changed.

Code:
var name = prompt("Please enter your name", "Herb");

Q:
I am testing the simplest webview I can come up with, but Lianja is not liking it.The inspector is telling me it has a parsing error.
A:
What file extension did you use for that file? If it is a dynamic server side JavaScript page it should have a .jssp file extension.In JavaScript you should terminate a statement with a ‘;’ After I added ‘;’ to the code no parse errors occurred. I have highlighted these in red. Although some javascript parsers will ignore the fact that the ; is missing, some will complain and if the code in minified then this causes an issue with the parser.

Code:
var  updatetext = function() {
    document.getElementById("herbinput").value = "test";};

window.onload = function(){    
   document.getElementById("herbbutton").onclick =  updatetext ;
};

Q:
am I correct in thinking that Lianja.evaluateJavaScript() when called from a client-side delegate will be able to fire server-side code and receive results + errors just as Lianja.evaluate() does?
A:
Yes that’s how Lianja.evaluateJavaScript() will work. Its the same as Lianja.evaluate() but for running server side code in different scripting languages.

 

 

Advertisements
Categories JS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s