1. Sivaprakash BKR
  2. PowerBuilder
  3. Wednesday, 19 October 2022 13:55 PM UTC

Hello,

Using PB 2019 R3 build 2703, Webbrowser control

Need to call a powerbuilder event from a html file with JS function(s).  How to call it?

Tried by going through few videos and codes from Appeon website.

Window consists of a webbrowser (wb_1) which display a login page<html>.  Login page consists of two fields and one button.
Two Fields:  userid & password
Button:       Login 
event :       ue_login

On click of the login button, it calls a js function loginprocess.   Code is given below.

function loginprocess()
{
	alert("login clicked");
	return window.webBrowser.ue_login();
}

In the above code, alert message gets displayed, but the event is not triggered.

Event is registered, in the open event of the window.

wb_1.RegisterEvent ( "ue_login" )

Is this the way to call a pb event from JS? 
If not, can you direct me to any link / document to achieve this?

Happiness Always
BKR Sivaprakash

 

Accepted Answer
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Thursday, 20 October 2022 06:38 AM UTC
  2. PowerBuilder
  3. # Permalink

Thanks John and Mark,

I started with the code from
https://community.appeon.com/index.php/codeexchange/powerbuilder/273-web-browser-demo-from-elevate-2020

then started modifying it to suit my need.   With your link and suggestion, I found the mistakes that I've done and corrected it. 
1.  JavaScript has to pass a String value to PB event.  I modified
2.  I registered the event in open event of the window.  It was wrong.   I moved it to navigationstart event.

With the above two corrections, it's working now. 

Happiness Always
BKR Sivaprakash

 

Comment
  1. John Fauss
  2. Thursday, 20 October 2022 13:22 PM UTC
That is great news! Thank you for describing what you had to change to resolve the issue. Would you please take a moment and mark this issue as resolved?
  1. Helpful 1
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Wednesday, 19 October 2022 16:01 PM UTC
  2. PowerBuilder
  3. # 1

I believe the PB user event MUST accept a single String argument value and return no value, or else the user event will not fire. I struggled with this for a long time until I found an obscure reference somewhere (I cannot recall where I found it documented). Of course, then the JavaScript also has to pass a String value to the registered user event.

It sure would be nice to have this clearly documented in the help for RegisterEvent.

I hope this helps.

Best regards, John

Comment
  1. Mark Goldsmith
  2. Wednesday, 19 October 2022 16:30 PM UTC
Hi John...agreed, you would think there would be a reference to these details or at least a link in the RegisterEvent Help information. That said, the Help information for this functionality is located under Working with WebBrowser -> Defining user events for WebBrowser (or here on-line: https://docs.appeon.com/pb2022/pbug/Defining_user_events_for_WebBrowser.html). Specifically, around passing arguments and returning values, you are correct on the single string argument but it can also return a string value.

Regards...Mark
  1. Helpful 4
  1. John Fauss
  2. Wednesday, 19 October 2022 17:40 PM UTC
Thank you, Mark, for calling out the obscure hiding place for this information, and for correcting me about the event return value. I appreciate you having my back!
  1. Helpful
  1. Miguel Leeuwe
  2. Thursday, 20 October 2022 19:51 PM UTC
That's great!

This link might also be useful if encountering any weird problems: https://www.appeon.com/standardsupport/search/view?id=6338

Regards.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.