Using JS to Clear a Widget's Bound Value

Use this board to ask questions or have discussions with other Rich Displays users.
DaveLClarkI
Experienced User
Posts: 165
Joined: Wed Dec 11, 2013 10:40 am
First Name: Dave
Last Name: Clark
Company Name: WinWholesale, Inc.
Phone: 937-294-5331
Address 1: 31101 Kettering Blvd.
City: Dayton
State / Province: Outside Canada/USA
Zip / Postal Code: 45439
Country: United States
Contact:

Using JS to Clear a Widget's Bound Value

Post by DaveLClarkI »

I have a hidden text box which is intended to pass a message from the RPG program to the JavaScript in my page. After my JavaScript gets the message, I want to programmatically clear that value so that my JavaScript doesn't react to it, again, until the next time the RPG program sends another message.

I'm using the following code but this doesn't seem to be doing it because I'm getting "ghost" reactions to the last message sent.

Code: Select all

wob.displayMessageText = function(widgetId, msgSource, fadeDuration, position, event)
{
	var messageText = get(msgSource.id);	// get any message text
	changeElementValue(msgSource.id, "");	// clear any message text
	if (messageText <= " ") return;			// if no message text, then exit

...snip...

}
Is there something else that needs to be done when the value of a widget is bound to an RPG variable?
User avatar
David
Profound Logic Staff Member
Posts: 690
Joined: Fri Jan 04, 2008 12:11 pm
First Name: David
Last Name: Russo
Company Name: Profound Logic Software
Contact:

Re: Using JS to Clear a Widget's Bound Value

Post by David »

Dave,

Was this one of the 3 items we talked about yesterday? Sorry, I've had quite a busy day today, I'll be following up on your other items, too.

Here it looks like you are doing it the right way, the changeElementValue() call will set the text box to empty string. There must be something else going on. Have you debugged the script to see exactly what happens? I ran a quick test and found no problems. Calling 'changeElementValue()' with empty string does properly clear the widget in all respects:

1. Visually cleared in the browser.

2. get() call after returns empty string.

3. Empty string submits to the server.

So, something else must be doing on or some other factor is in play. Is this one of those cases you mentioned where you have different widget types bound to same field or anything like that?
DaveLClarkI
Experienced User
Posts: 165
Joined: Wed Dec 11, 2013 10:40 am
First Name: Dave
Last Name: Clark
Company Name: WinWholesale, Inc.
Phone: 937-294-5331
Address 1: 31101 Kettering Blvd.
City: Dayton
State / Province: Outside Canada/USA
Zip / Postal Code: 45439
Country: United States
Contact:

Re: Using JS to Clear a Widget's Bound Value

Post by DaveLClarkI »

Yes, this is one of three three things I mentioned as outstanding issues in Thursday's meeting. But, no, this is not a case of multiple widgets trying to use the same bound field. After the script runs and before submitting back to the server, I did a Ctrl-F9 of the screen and I can still see the message text showing in the bound RPG field. Is that normal?
User avatar
David
Profound Logic Staff Member
Posts: 690
Joined: Fri Jan 04, 2008 12:11 pm
First Name: David
Last Name: Russo
Company Name: Profound Logic Software
Contact:

Re: Using JS to Clear a Widget's Bound Value

Post by David »

Yes, it would be normal to see it still in the CTRL+F9 dump.

This is a capture of the last data that was received by the browser from the server. So it will have the data as at the time of screen render. It's not updated by the browser.

A good way to see what is submitted to the server if you want to check that is to use the browser's network request monitor. Try F12 tools in IE, Network tab.

You can see the POST request to program PUI0002110, which is the Genie server program.
DaveLClarkI
Experienced User
Posts: 165
Joined: Wed Dec 11, 2013 10:40 am
First Name: Dave
Last Name: Clark
Company Name: WinWholesale, Inc.
Phone: 937-294-5331
Address 1: 31101 Kettering Blvd.
City: Dayton
State / Province: Outside Canada/USA
Zip / Postal Code: 45439
Country: United States
Contact:

Re: Using JS to Clear a Widget's Bound Value

Post by DaveLClarkI »

I'm going to need some help, then, figuring out why I'm getting "ghost" reactions to the last message sent. Basically, even through the message is not being sent from the RPG program (confirmed by interactive debug on the RPG program), the get(msgSource.id) function in the JavaScript is returning the previous message text such that it displays on the screen again and again.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Using JS to Clear a Widget's Bound Value

Post by Scott Klement »

As an aside, I find this code confusing, maybe someone can explain it to me?

Code: Select all

   if (messageText <= " ") return;         // if no message text, then exit
It's the <= " " part that baffles me. You are looking for strings that are less than blanks? Is an empty string less than a blank? Or more? How can you even quantify what an empty string will be?

I suspect that you know from prior experience than an empty string is less than a blank (why else would you code this) but to me it's quite puzzling. I would've found it much clearer if you trimmed the blanks from messageText and then compared against an empty string ("").

Am I right? OR, can you explain what that actually does when you set a string to "" and then compare it to <= " "?
User avatar
David
Profound Logic Staff Member
Posts: 690
Joined: Fri Jan 04, 2008 12:11 pm
First Name: David
Last Name: Russo
Company Name: Profound Logic Software
Contact:

Re: Using JS to Clear a Widget's Bound Value

Post by David »

It's hard to say what is going wrong here from the limited details.

Do you have a simple example that demonstrates the problem that we could try here?
DaveLClarkI
Experienced User
Posts: 165
Joined: Wed Dec 11, 2013 10:40 am
First Name: Dave
Last Name: Clark
Company Name: WinWholesale, Inc.
Phone: 937-294-5331
Address 1: 31101 Kettering Blvd.
City: Dayton
State / Province: Outside Canada/USA
Zip / Postal Code: 45439
Country: United States
Contact:

Re: Using JS to Clear a Widget's Bound Value

Post by DaveLClarkI »

Simple? No, I'll have to send you my objects like I did for the tab panel issue. Working on it...
User avatar
David
Profound Logic Staff Member
Posts: 690
Joined: Fri Jan 04, 2008 12:11 pm
First Name: David
Last Name: Russo
Company Name: Profound Logic Software
Contact:

Re: Using JS to Clear a Widget's Bound Value

Post by David »

Not sure if you received my email on this? I had sent you FTP account details where you could upload the example.
DaveLClarkI
Experienced User
Posts: 165
Joined: Wed Dec 11, 2013 10:40 am
First Name: Dave
Last Name: Clark
Company Name: WinWholesale, Inc.
Phone: 937-294-5331
Address 1: 31101 Kettering Blvd.
City: Dayton
State / Province: Outside Canada/USA
Zip / Postal Code: 45439
Country: United States
Contact:

Re: Using JS to Clear a Widget's Bound Value

Post by DaveLClarkI »

Yes, uploaded last night and sent email with instructions.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests