PDA

View Full Version : referencing a textbox in javascript canvas in a browser



hmischel@diligentsystems.com
2014-12-17, 20:30
I'm possibly having another brain freeze.

Using the tried and true Lianja.get("page.section.field") works fine until I try it in a web page.

Looking at example_webapp3, the fields are simply referenced directly by their name. No page, no section, just name.

For example, this is used to clear the fields when a button is clicked.


function page1_section2_field23_click()
{
m_companyname.text = "";
m_companyregion.text = "";
}


I was certain that this
Lianja.get("page.section.field") was working before.

Thanks.

Herb

barrymavin
2014-12-17, 22:14
Hi Herb,

Yes you reference the fields directly by variable name in both desktop and web for javascript canvas sections.

yvonne.milne
2014-12-18, 05:34
Hi Herb,

Note, that this applies to the Canvas controls (http://www.lianja.com/resources/blog/39-coding-tips/412-the-lianja-html5-client#p8). If you wanted to reference a formitem in the 'Customer' Form Section in example_webapp3, you would use the Lianja.get() syntax, e.g.


////////////////////////////////////////////////////////////////
// Event delegate for 'click' event
function page1_section2_field23_click()
{
m_companyname.text = "";
m_companyregion.text = "";
messagebox(Lianja.get('page1.section1.field1').tex t);
}

Regards,

Yvonne

hmischel@diligentsystems.com
2014-12-21, 08:48
Hi Yvonne,

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.


Thanks.

Herb

barrymavin
2014-12-21, 20:47
Hi Herb,

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.

hmischel@diligentsystems.com
2014-12-21, 21:27
The Dialog is a simple javascript canvas with one commandbutton and one textfield.

The onlick of the commandbutton is as follows.


messagebox("dialog box");
m_dlg1.text ="dialog";
messagebox(m_dlg1.text);


When I run this page as an app directly, all three lines work.

When I call this page from another page, the first line works ( a messagebox appears, then the next two lines do not).

I call the page this way.


Lianja.showdialogpanel("","dlgJSCanvas1",500,undefined,undefined,undefined,1);

Am I doing something wrong?

Thanks.

Herb

barrymavin
2014-12-21, 21:32
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.

Right click on the WebView and look in the console it will show you any errors.

barrymavin
2014-12-21, 21:34
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.

hmischel@diligentsystems.com
2014-12-21, 21:40
OK - thanks for clearing that up for me.

barrymavin
2014-12-21, 21:57
For a blocking messagebox() you can use confirm() in JavaScript.



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

barrymavin
2014-12-21, 22:02
And for an inputBox() you can use prompt(). The trouble with all these is that they have a "JavaScript" title which cannot be changed.



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