Call/Run a ProfoundUI RPG program from a Java based web app

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
doklee
New User
Posts: 6
Joined: Fri Sep 13, 2013 6:25 am
First Name: Dok
Last Name: Lee
Company Name: Doklee
Contact:

Call/Run a ProfoundUI RPG program from a Java based web app

Post by doklee »

Ok, so I've been trying for days and cant seem to find the answer or make it work alone. I have two things in play:
* A ProfoundUI web enabled RPG system
* A Java based web application hat runs on Tomcat (Windows Server)

I'm calling legacy back-end RPG programs via IBM's Java toolkit. I can pass parms back and forth between the two and all is grand.

What I'm trying to do now is call one of my ProfoundUI RPG's (one with a screen) from my Java web application and actually render the screen inside the browser.

Any advice and/or tips on how to make this happen?

Thx in advance!
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: Call/Run a ProfoundUI RPG program from a Java based web app

Post by Scott Klement »

It's not possible to display a screen through IBM's Java toolkit. Programs run this way are not run inside the HTTP server, and cannot communicate with the browser, so they cannot display a screen.

However, you should be able to start a Profound UI application by invoking a URL from within the browser -- which can be started by the Java app. Like all Profound UI programs, you'd do this either by starting a session (which requires the user to sign on, and then shows his initial program) or by invoking an anonymous program (without sign-on). You'd use the same URLs that you use to start PUI by hand in the browser.

Does that help?
doklee
New User
Posts: 6
Joined: Fri Sep 13, 2013 6:25 am
First Name: Dok
Last Name: Lee
Company Name: Doklee
Contact:

Re: Call/Run a ProfoundUI RPG program from a Java based web app

Post by doklee »

Yes that is a great help. I'm more on the Java side of the house so I'm not in the profound system/tools that often. I found some documentation related to the Anonymous sessions. I created a sample CL program and added it to pui0001200. In the CL I'm adding a few libraries, then calling a simple list program (which is profound UI'd).

If I call my CL directly from: http://mysystem:8080/profoundui/genie, it works perfect.
But if I navigate to it via: http://mysystem:8080/profoundui/start?pgm=mylib/mypgm, it blows.

I had some permissions issues initially which i corrected for user QTMHHTP1 which I got corrected. The error is very generic: Error found on call command.

This might be something simple that most Profound customers can overcome, but as I said I'm not in the details of Profound daily.

Any more help/breadcrumbs would be much appreciated.

Thanks.
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: Call/Run a ProfoundUI RPG program from a Java based web app

Post by Scott Klement »

Are there any previous messages in the job log (before the "Error on call command") that might provide a clue as to what the problem is?

The most common reasons something would work in Genie but not from an anonymous URL would be:
  • Authority difference between regular user vs QTMHHTP1
  • Library list is different in Genie vs. HTTP server.
But, of course, there are a million possibilities... those are just the most common ones. See if the job log helps tell you the problem.
doklee
New User
Posts: 6
Joined: Fri Sep 13, 2013 6:25 am
First Name: Dok
Last Name: Lee
Company Name: Doklee
Contact:

Re: Call/Run a ProfoundUI RPG program from a Java based web app

Post by doklee »

Yep found it in the joblog. Ok, got past that and all is well. I'm running my program via the URL as an anonymous session. Working great.

One more question - Can I run the URL from my Java web app and somehow retrieve back into my Java world parameter data? For example, if I am running this simple list program, which allows user to select something in the list - what is the best way to return that selection to my web app?

Thanks.
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: Call/Run a ProfoundUI RPG program from a Java based web app

Post by Scott Klement »

doklee wrote:One more question - Can I run the URL from my Java web app and somehow retrieve back into my Java world parameter data? For example, if I am running this simple list program, which allows user to select something in the list - what is the best way to return that selection to my web app?
I can't think of a simple way. To summarize: You will have opened up the RPG program on the server, and the Profound UI display running in the browser. The Profound UI display will have returned it's data to the RPG program. So, now you want that RPG program to somehow return data back to your Java program.

The problem here (as with all web apps) is that the web page isn't driven by your Java program -- it's driven by the browser. So it's a very different scenario than invoking an RPG program via the JTOpen toolkit, where the toolkit is a parent process of the RPG program. In this case, the browser is (and has to be) the parent process. Having an RPG program invoke your Java program would have the same problem, if the Java program was interfacing as a web page.

But there are certainly ways to make this work:
  • Display the Profound UI screen directly from your Java program, if you don't need the RPG program's intervention.
  • Have the RPG program communicate with the Java program using a data queue or socket. This would make it easy to pass data back and forth, and notify the Java program when stuff is finished/ready.
  • Code some AJAX in your display that sends data to the Java program.
There are probably other ways, but those are the ones that come to mind. Obviously, these are somewhat more complicated methods than the one you were trying for -- but, that's about all you can do, here.

Now if it's possible to put the RPG program in control (instead of the Java program) this could be very easy... The RPG program could just call the JAva methods at the appropriate time.

Or... if it's possible to eliminate the Java program, and just do everythign in RPG, that would greatly simplify things, too.
doklee
New User
Posts: 6
Joined: Fri Sep 13, 2013 6:25 am
First Name: Dok
Last Name: Lee
Company Name: Doklee
Contact:

Re: Call/Run a ProfoundUI RPG program from a Java based web app

Post by doklee »

Ok Thanks. I was hoping there was some good back-n-forth that was easy. Sounds like maybe the DataQ option is the best hope. I'll give it a whirl!

Thanks for the help.
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: Call/Run a ProfoundUI RPG program from a Java based web app

Post by Scott Klement »

One more idea (courtesy of a colleague of mine):

If your Java program is already displaying a page in a browser, you could use Javascript to notify that page of the selected value. For example:
  • Java program invokes Profound UI with window.open()
  • An 'onclick' or 'onrowclick' (or similar) is coded when the user selects something in the subfile.
  • The onclick/onrowclick does something like window.opener.document.getElementById("your-element").value = "whatever". This way, it can set a value in the window where Java invoked PUI from.
  • Optionally, the Java window could even do window.close() to shut down the PUI session after the selection has been made.
So that's another approach -- I don't know if it applies here, since a lot will depend on exactly how your application works -- but I thought I'd throw it out there in case it'd be useful to you.
doklee
New User
Posts: 6
Joined: Fri Sep 13, 2013 6:25 am
First Name: Dok
Last Name: Lee
Company Name: Doklee
Contact:

Re: Call/Run a ProfoundUI RPG program from a Java based web app

Post by doklee »

Thanks. I'm still working on it. I've still not gotten the link to work but am working on it today. But what about situations where there is not a link to click? Maybe I just want to return a success flag of some kind or some notification of the last action performed, etc...

Does that force me in to the the socket or dataQ options? I've done RPG/CGI programming, but am unsure of how to write to http within Profound RPG programs.

Thanks.
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: Call/Run a ProfoundUI RPG program from a Java based web app

Post by Scott Klement »

I'm not sure I follow you. Why would you need a link to click?

In order to return informaion (success flag, or anything else) you'd use the techniques I suggested, above.
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests