Executing a Hyperlink command within RPG
-
- New User
- Posts: 14
- Joined: Tue Nov 26, 2013 11:12 am
- First Name: sheri
- Last Name: mcpherson
- Company Name: winwholesale, inc.
- Contact:
Executing a Hyperlink command within RPG
Is it possible to execute a Hyperlink command, such as I have in ProfoundUI to execute it pui.click("RichDataHL")? This displays a URL that the RPG program has created in another browser window. Thanks!
-
- 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: Executing a Hyperlink command within RPG
Assuming "RichDataHL" is the id of a hyperlink widget, and that widget has either a 'response', 'shortcut key', or 'onclick' defined, then it should work.
Is that what you're doing?
Is that what you're doing?
-
- New User
- Posts: 14
- Joined: Tue Nov 26, 2013 11:12 am
- First Name: sheri
- Last Name: mcpherson
- Company Name: winwholesale, inc.
- Contact:
Re: Executing a Hyperlink command within RPG
The RichDataHL is the id of a field we have called WebAppUrl on ProfoundUI. That field has a onclick property defined to do the following: window.open(this.pui.properties["hyperlink reference"]);
How can I execute the onclick action from RPG code? It works beautifully when clicked on within PUI, my challenge is how to execute the command from RPG. I hope this makes sense. :)
How can I execute the onclick action from RPG code? It works beautifully when clicked on within PUI, my challenge is how to execute the command from RPG. I hope this makes sense. :)
-
- 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: Executing a Hyperlink command within RPG
Perhaps you can run pui.click() from your screen's 'onload' event? This way, when RPG does EXFMT, it triggers the hyperlink..
-
- New User
- Posts: 14
- Joined: Tue Nov 26, 2013 11:12 am
- First Name: sheri
- Last Name: mcpherson
- Company Name: winwholesale, inc.
- Contact:
Re: Executing a Hyperlink command within RPG
The problem with that is its only executed from a Menu widget we have built in ProfoundUI and we have it conditional to show different text at different times. :(
-
- 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: Executing a Hyperlink command within RPG
I'm not sure that I understand... you said you wanted to execute a hyperlink widget's onclick function from an RPG program. How does this relate to a menu widget? Is it that you want to execute the hyperlink widget from the menu widget?
-
- New User
- Posts: 14
- Joined: Tue Nov 26, 2013 11:12 am
- First Name: sheri
- Last Name: mcpherson
- Company Name: winwholesale, inc.
- Contact:
Re: Executing a Hyperlink command within RPG
I am not sure now. :)
Let me show you a little bit of the code that I am stumped on maybe that will help.
When a Menu option is clicked the value of the menu option will equal 'Rich'. Then the RPG program will execute and a select statement below will be executed and as you can see I have nothing to execute at this level because I do not know how to execute the hyperlink from there.
Select;
// Copy clicked
When outDtlAct = 'Copy';
iCpyLnItm = *on;
InsertOrUpdateDetailLines();
// Rich Data clicked
When outDtlAct = 'Rich';
//pui.click("RichDataHL");
Let me show you a little bit of the code that I am stumped on maybe that will help.
When a Menu option is clicked the value of the menu option will equal 'Rich'. Then the RPG program will execute and a select statement below will be executed and as you can see I have nothing to execute at this level because I do not know how to execute the hyperlink from there.
Select;
// Copy clicked
When outDtlAct = 'Copy';
iCpyLnItm = *on;
InsertOrUpdateDetailLines();
// Rich Data clicked
When outDtlAct = 'Rich';
//pui.click("RichDataHL");
-
- 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: Executing a Hyperlink command within RPG
You can't call pui.click() from an RPG program... The RPG program is running on IBM i, whereas pui.click() needs to run in the end-user's PC inside their web browser. So it's a different environment. What you need to do instead is display a PUI screen (which runs in the browser) and have code in that screen execute the URL.
With that in mind, you'd want your RPG code to look something like this:
The idea here is that when you execute your screen, it can run some JavaScript code automatically using the 'onload' event. This code executes as soon as the screen is loaded, and can potentially re-submit your screen to the RPG program (if you don't want to wait for user input.) If your screen is used for other things besides just running this URL, then you will want some sort of a flag to indicate when you're doing the automatic click (or not), so I thought maybe a good way would be to have a hidden output field bound to an RPG variable named 'AutoClick' would be a good way, set this to Y if you want it to automatically open the hyperlink, or N if not.
So on your display:
Does that make more sense?
With that in mind, you'd want your RPG code to look something like this:
Code: Select all
Select;
// Copy clicked
When outDtlAct = 'Copy';
iCpyLnItm = *on;
InsertOrUpdateDetailLines();
// Rich Data clicked
When outDtlAct = 'Rich';
//pui.click("RichDataHL");
AutoClick = 'Y';
exfmt THESCREEN;
AutoClick = 'N';
So on your display:
- Drag in an output-field. Bind it to 'AutoClick' field, which is Character, length 1. Also set the 'id' of the field to: AutoClick
- In the screen-level properties, find the 'onload' event.
- Set the onload event to something like this:
Code: Select all
if (get("AutoClick") == "Y") {
// Open window to hyperlink reference
window.open(getObj("RichDataHL").pui.properties["hyperlink reference"]);
// resubmit screen back to RPG program without waiting for user.
pui.click();
}
-
- New User
- Posts: 3
- Joined: Thu Dec 12, 2013 12:36 pm
- First Name: Lesley
- Last Name: Gill
- Company Name: WinWholesale
- Phone: 9377185843
- Address 1: 3110 Kettering Blvd
- City: Dayton
- State / Province: Outside Canada/USA
- Zip / Postal Code: 45439
- Country: United States
- Contact:
Re: Executing a Hyperlink command within RPG
That works very nicely. Thank you Scott.
Who is online
Users browsing this forum: No registered users and 3 guests