Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

New TIBCO Community Coming Soon
In early summer, TIBCO plans to launch a new community—with a new user experience, enhanced search, and expanded capabilities for member engagement with answers and discussions! In advance of that, the current myibi community will be retired on April 30. We will continue to provide updates here on both the retirement of myibi and the new community launch.

What You Need to Know about Our New Community
We value the wealth of knowledge and engagement shared by community members and hope the new community will continue cultivating networking, knowledge sharing, and discussion.

During the transition period, from April 20th until the new community is launched this summer, myibi users should access the TIBCO WebFOCUS page to engage.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOVED] Maintain onBlur event handler acting strange

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOVED] Maintain onBlur event handler acting strange
 Login/Join
 
Gold member
posted
Hi everyone,

I have run into a problem that has me scratching my head. I have a maintain project that has two tables...one for person info and another for order info. My goal is to add an event handler(either onChange or onBlur) that executes when someone enters a PersonID on an AddOrderForm. The code should check the Person table to see if that PersonId exists, and if it does exist display the persons name on the screen. If it doesn't a JS confirm box should pop-up asking the user if they would like to add a new Person record. The code that checks to see if the person exists follows
 STACK CLEAR GetPersonStack;
REPOSITION fow_clients.FOW_CLIENTS.PERSONID;
NEXT fow_clients.FOW_CLIENTS.PERSONID INTO GetPersonStack WHERE fow_clients.FOW_CLIENTS.PERSONID EQ AddOrderStack(1).PERSONID;
COMPUTE exist=GetPersonStack.FocCount; 

I bound the variable 'exist' to a hidden field on the form where the JS function can look. If the value is 1 then display the name...if it is 0 then display confirm box asking to enter new Person record. The problem is that the JS function fires off before Maintain can set the value in the hidden field, so JS always sees 0 in the field even if there is a Person record corresponding to the PersonID. I have tried making the event handler JS, and having it call the above Maintain code...then use a setTimeout command to give Maintain a chance to populate the 'exist' editBox, but this doesn't seem to work either. When I test the app I can see that the field is being populated with a 1 only after the event handler has completed. The Person table only has a few hundred records so it doesn't take long for Maintain to find the record, but that field only populates when the event handler is over.

If anyone has any suggestions or alternate ideas on how to achieve this functionality I am all ears.


P.S. on a related note why does the focus always return to the PersonID field when I run this event handler? Even when I explicitly set the focus to another field the focus returns to PersonID after having tabbed off the field and launching the event handler. When the event handler is onChange this isn't a major issue because if you hit tab again you move to the next field, but when it is onBlur you just get stuck tabbing and then returning over and over again.


Thanks

This message has been edited. Last edited by: brjohnson,


Bryan Johnson
WebFOCUS 7.7.03
Maintain
Win 7
Excel, PDF, HTML
 
Posts: 54 | Registered: January 16, 2008Report This Post
Virtuoso
posted Hide Post
Bryan,

Am I right in assuming that you bound the js function that checks the hidden field to the onchange event?
If so, then what happens is making sense.
Consider the timing in this. When something changes in the id field, then the js gets activated. This one does two things - call a maintain case, and checks the field.
But, these two things are mutually exclusive, because the first takes place on the server (requiring the js to exit) and the other one locally (requiring the js not to exit).
Split the js functions.
One to act upon the change of the field and call the maintain case.
This will return control to the server and result in a new page, with all data filled in.
This function needs to be bound to the id-field.
Then have a second js function that will act upon the value of the hidden field. This piece of js has to be bound to the form itself (done by dragging the js from the project explorer onto an empty space on the open form). This latter js will get executed after the page has been loaded.

Hope this helps ...


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Master
posted Hide Post
There are actually 2 ways that I would do this.

The first is just with Maintain and not JavaScript. I would place a button or a text message on the form and make it Visible No. Then, if the person is not found, I would use:
WINFORM SET form.object.visible to YES

This displays the message and you can trigger what ever you want. Make it Visible NO when you are done.

The second is a JavaScript solution, but uses the OnLoad.JS funtion. This is attached to the form, and is run EVERY time the form is refreshed. So, you could have:

var OriginalOnload = document.body.onload;
document.body.onload = LoadFunct;

function LoadFunct() {
if (OriginalOnload) OriginalOnload ();
if (document.Display.X_Edit.value.length != 0)
{
var msgtext = Display.X_Edit.value;
alert(msgtext);
Display.X_Edit.value = '';
}
}

This routine checks a field on the form, and if it has a value, pop up a message. You could have it kick off another JavaScript routine or whatever else you need. Just remember to clear out the checked field when done, or the message will be displayed everytime.

Mark
 
Posts: 663 | Location: New York | Registered: May 08, 2003Report This Post
Gold member
posted Hide Post
Thanks very much both of you,

I was able to get it working...I chose to use the Maintain only strategy for checking for the user. I used the JS onLoad function to set the focus to the field after ID, if the ID field contains data, to prevent an endless tabbing loop. Just one thing still kinda bugs me(and its not a real big deal) the data in the ID field remains highlighted even though the focus is set on the next field. Like I said its not a big problem, but I was just curious if anyone knew why this was happening.

Thanks again for the help


Bryan Johnson
WebFOCUS 7.7.03
Maintain
Win 7
Excel, PDF, HTML
 
Posts: 54 | Registered: January 16, 2008Report This Post
Platinum Member
posted Hide Post
quote:
Just one thing still kinda bugs me(and its not a real big deal) the data in the ID field remains highlighted even though the focus is set on the next field.


Set the .select method as well as the .focus, and that should take care of it.


Regards,
Dave

http://www.daveayers.com

WebFocus/Maintain 7.6.4-8
on Win2000 and 2003 Server
 
Posts: 165 | Location: Detroit Metro | Registered: September 17, 2003Report This Post
Gold member
posted Hide Post
That did take care of it...also while searching the forum I found this snippet of code from Mark that will set focus completely with Maintain.
 WINFORM SET FormName.FieldName.Focus to HERE; 
This works just fine...no javascript needed.


Bryan Johnson
WebFOCUS 7.7.03
Maintain
Win 7
Excel, PDF, HTML
 
Posts: 54 | Registered: January 16, 2008Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOVED] Maintain onBlur event handler acting strange

Copyright © 1996-2020 Information Builders