Setup for JSON using a Universal Display File.
-
- New User
- Posts: 7
- Joined: Tue Jan 13, 2015 11:00 pm
- First Name: Todd
- Last Name: Cameron
- Company Name: Blood Bank Computer Systems
- Address 1: 1002 15th St SW
- City: Auburn
- State / Province: Washington
- Zip / Postal Code: 98001
- Country: United States
- Contact:
Setup for JSON using a Universal Display File.
Issue:
I am attempting to create some JSON in Universal. When I call my program via https://myServer:8080/DEVPRFND/universal/gjmenu, The job is running under user QTMHHTP1 and with without the needed library list. I need both the USER and the LIBL fomr the JOBD and the Current lib. The program is called and will return a JSON string to an AJAX container. (hope I got that right)
This is the library list it runs under:
Opt Library Type Device Text
QSYS SYS System Library
QSYS2 SYS System Library for CPI's
QHLPSYS SYS
QUSRSYS SYS System Library for Users
DEVPRFND CUR ProfoundUI by Profound Logic Software,
QGPL USR General Purpose Library
QTEMP USR
I have hardcoded the display file so that it could be found without a library list.
Program GJMENU:
*************** Beginning of data ***********************************
H DftActGrp(*No)
FGJMENUUD CF E WORKSTN Handler('UNIVERSAL(HANDLER)')
F ExtFile('DEXPOBJ/GJMENUUD')
D myUser S 10 inz(*user)
/free
write JSON;
*InLR= *ON;
/end-free
****************** End of data **************************************
These are the Service Programs bound to the GJMENU program
Opt Program Library
QRNXIE QSYS
QRNXIO QSYS
QRNXUTIL QSYS
QLEAWI QSYS
I see discussions about SyncJob() and think it may apply, but…
1. I do not have a binding directory PROFOUNDI.
2. The Universal Display controller should automatically be calling SyncJob() for you.
Display a Database Record
Base PF: PUIMAPP Library: DEVPRFND Member: PUIMAPP RRN: 000000003
Field Name Field Description Field Value
URIMAP URI MAPPING /GJMENU
LIBRARY PROGRAM LIBRARY DEXPOBJ
PROGRAM PROGRAM NAME GJMENU
SIGNON REQUIRE SIGNON
Can you explain how I can make my Universal files use the same user id and library list as for the Rich Text Display Files?
I am attempting to create some JSON in Universal. When I call my program via https://myServer:8080/DEVPRFND/universal/gjmenu, The job is running under user QTMHHTP1 and with without the needed library list. I need both the USER and the LIBL fomr the JOBD and the Current lib. The program is called and will return a JSON string to an AJAX container. (hope I got that right)
This is the library list it runs under:
Opt Library Type Device Text
QSYS SYS System Library
QSYS2 SYS System Library for CPI's
QHLPSYS SYS
QUSRSYS SYS System Library for Users
DEVPRFND CUR ProfoundUI by Profound Logic Software,
QGPL USR General Purpose Library
QTEMP USR
I have hardcoded the display file so that it could be found without a library list.
Program GJMENU:
*************** Beginning of data ***********************************
H DftActGrp(*No)
FGJMENUUD CF E WORKSTN Handler('UNIVERSAL(HANDLER)')
F ExtFile('DEXPOBJ/GJMENUUD')
D myUser S 10 inz(*user)
/free
write JSON;
*InLR= *ON;
/end-free
****************** End of data **************************************
These are the Service Programs bound to the GJMENU program
Opt Program Library
QRNXIE QSYS
QRNXIO QSYS
QRNXUTIL QSYS
QLEAWI QSYS
I see discussions about SyncJob() and think it may apply, but…
1. I do not have a binding directory PROFOUNDI.
2. The Universal Display controller should automatically be calling SyncJob() for you.
Display a Database Record
Base PF: PUIMAPP Library: DEVPRFND Member: PUIMAPP RRN: 000000003
Field Name Field Description Field Value
URIMAP URI MAPPING /GJMENU
LIBRARY PROGRAM LIBRARY DEXPOBJ
PROGRAM PROGRAM NAME GJMENU
SIGNON REQUIRE SIGNON
Can you explain how I can make my Universal files use the same user id and library list as for the Rich Text Display Files?
-
- 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: Setup for JSON using a Universal Display File.
The userid/libl should be automatically synched when called from a choices url, data url, or chart url property of a Profound UI widget. (the special URL properties of Textbox, Combo Box, Drop-down/Select box, Grid or Chart.)
You say that it's not synching for you? Can you tell me which type of widget you are calling it from, so I can verify that it's not a bug in that widget?
Also, you mention you do not have a PROFOUNDI binding directory. Did you mean PROFOUNDUI? If so, I wonder why you don't have that? It's included in the save file that our installer installs, and lots of other customers are using it. That's very strange that it would be missing... Was there an error or something when you installed the product that some of the objects might not have gotten installed?
You say that it's not synching for you? Can you tell me which type of widget you are calling it from, so I can verify that it's not a bug in that widget?
Also, you mention you do not have a PROFOUNDI binding directory. Did you mean PROFOUNDUI? If so, I wonder why you don't have that? It's included in the save file that our installer installs, and lots of other customers are using it. That's very strange that it would be missing... Was there an error or something when you installed the product that some of the objects might not have gotten installed?
-
- New User
- Posts: 7
- Joined: Tue Jan 13, 2015 11:00 pm
- First Name: Todd
- Last Name: Cameron
- Company Name: Blood Bank Computer Systems
- Address 1: 1002 15th St SW
- City: Auburn
- State / Province: Washington
- Zip / Postal Code: 98001
- Country: United States
- Contact:
Re: Setup for JSON using a Universal Display File.
This was indeed a type on WRKBNDDIR BNDDIR(*ALL), but, No I am missing the PROFOUNDUI binding directory. I am not too concerned because we are still using an old demo version having just signed up and purchased a license in the last week or so and will see if I can get this updated right away.
I am using the Panels > AJAX Container widget for this test. I believe this to be a choice url.
I am using the Panels > AJAX Container widget for this test. I believe this to be a choice url.
-
- 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: Setup for JSON using a Universal Display File.
I think for the AJAX container, we assume anyone who is doing his own AJAX coding will be happy/willing to do this coding himself. It's a simple matter of adding the AUTH= parameter to the URL, I can show you how to do that if you like.
But, normally when you use the AJAX container, your code would output HTML (you said your code is outputting JSON). I wonder why you are using the AJAX container if your goal is to work with JSON data?
Can you tell me a little more about what you're attempting to use this for? What does the program that you're running via AJAX do? If I understood this a bit better, it'd be much easier to make recommendations on the best way to proceed..
But, normally when you use the AJAX container, your code would output HTML (you said your code is outputting JSON). I wonder why you are using the AJAX container if your goal is to work with JSON data?
Can you tell me a little more about what you're attempting to use this for? What does the program that you're running via AJAX do? If I understood this a bit better, it'd be much easier to make recommendations on the best way to proceed..
-
- New User
- Posts: 7
- Joined: Tue Jan 13, 2015 11:00 pm
- First Name: Todd
- Last Name: Cameron
- Company Name: Blood Bank Computer Systems
- Address 1: 1002 15th St SW
- City: Auburn
- State / Province: Washington
- Zip / Postal Code: 98001
- Country: United States
- Contact:
Re: Setup for JSON using a Universal Display File.
The AJAX container was for testing only.
Here is what we are trying to accomplish:
We are creating a custom menu presentation of programs a user can call.
I am to provide a list of those programs (and dependencies, properties, and other pieces for context)
The list is based on the user id and the authority to the programs on the iSeries.
Others on my team are comfortable with JSON and ask that I provide a JSON string listing all the programs, and associated values to which the user is authorized.
How we are proceeding:
Using HTTPS and a custom client version of the Profound Logic sign on screen we present the new menu. The menu application is a combination of the processed JSON which replaces the display content of an existing program, but uses the existing RPG validation underneath.
The RPG program needed needs to know who is signed on and return a JSON list of authorized programs.
Notes:
1. I have developed formatted output using the Universal File and would like to use that in developing the JSON output. It is good for HTML also, but now what is being requested.
2. You mention the AUTH=XXXXXXXX parameter. Yes I think I need to know what that parameter is. By its name I sense that it may be the key to this issue and will see what documentation I can find on it over the weekend.
Here is what we are trying to accomplish:
We are creating a custom menu presentation of programs a user can call.
I am to provide a list of those programs (and dependencies, properties, and other pieces for context)
The list is based on the user id and the authority to the programs on the iSeries.
Others on my team are comfortable with JSON and ask that I provide a JSON string listing all the programs, and associated values to which the user is authorized.
How we are proceeding:
Using HTTPS and a custom client version of the Profound Logic sign on screen we present the new menu. The menu application is a combination of the processed JSON which replaces the display content of an existing program, but uses the existing RPG validation underneath.
The RPG program needed needs to know who is signed on and return a JSON list of authorized programs.
Notes:
1. I have developed formatted output using the Universal File and would like to use that in developing the JSON output. It is good for HTML also, but now what is being requested.
2. You mention the AUTH=XXXXXXXX parameter. Yes I think I need to know what that parameter is. By its name I sense that it may be the key to this issue and will see what documentation I can find on it over the weekend.
-
- 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: Setup for JSON using a Universal Display File.
So, if I understand correctly, when the user has typed their userid and moved to the password field you're going to fire-off an AJAX request to the server and it's going to return a list of progams that they are allowed to use?
One issue there... since the sign-on screen has not yet been submitted to Profound UI, the job will not yet be running with that userid's authority, so syncing the userid/password with your JSON webservice won't work at that point. You'd need to wait until the next screen (or later than that) for the userid/password to have been accepted, so that the job is running with the user's authority.
As far as how you'd make the AJAX request in this case, I don't think I'd use the AJAX container. These are the things I'd try to use if they fit your needs (in order of preference):
One issue there... since the sign-on screen has not yet been submitted to Profound UI, the job will not yet be running with that userid's authority, so syncing the userid/password with your JSON webservice won't work at that point. You'd need to wait until the next screen (or later than that) for the userid/password to have been accepted, so that the job is running with the user's authority.
As far as how you'd make the AJAX request in this case, I don't think I'd use the AJAX container. These are the things I'd try to use if they fit your needs (in order of preference):
- Use one of our widgets, like the drop-down ("select box") with database-driven logic. You can fill in the parameters for the userid, et al, and refresh the drop-down all from JavaScript. It'll load the data directly from your files. No need to write any special server-side logic.
- Use the drop-down (or similar) with a 'choices url' to call your web service. This might work better for you if the process to read your list of programs is too complex to use the database-driven support for some reason.
- If you need to do this with a widget that doesn't have database-driven capabilities, then use the ajax API (rather than the container.) The API returns the results to your JavaScript code (whereas the widget tries to display it on the screen) so you can write the logic to populate any fields you wish. For example, check out the ajaxJSON routine.
-
- New User
- Posts: 7
- Joined: Tue Jan 13, 2015 11:00 pm
- First Name: Todd
- Last Name: Cameron
- Company Name: Blood Bank Computer Systems
- Address 1: 1002 15th St SW
- City: Auburn
- State / Province: Washington
- Zip / Postal Code: 98001
- Country: United States
- Contact:
Re: Setup for JSON using a Universal Display File.
Almost right except we have already signed on to the iSeries-
The sequence is:
1. The User has already signed on
2. At the on-load event for the initial program we want to retrieve the list of programs for the user.
We create our own display/filters/sorts/ and custom component displayed in a content pane.
The RPG program will be available when the on-load is complete but is moved off the screen so that it is in effect hidden to the user.
3. When the user selects a menu option it will be forwarded to the hidden RPG screen for processing. This preserves the existing RPG edits and processing we already use. In effect we are just replacing the display content and adding sort/filter functionality to the display portion.
Management has outlined client side functionality that I believe to be well into your option 3, the ajaxJSON routine to retrieve and display content. I have read the ajaxJSON example referenced and it does read and write to the environment and works fine except that there is no user or library list associated with it. The example is in fact what I based my initial work on. The the crux of the issue is still that I would like to have the user and libl without having to generate it each time I do an ajax call via a URL. Is this related to the AUTH=xxxxx parameter? That appears to be a profound parameter for a URL call, It seems hopeful at this point.
Current thoughts for approach
Here is what I am looking at. In the URL string to a universal display file there is the ability to map and design values into the JSON string. If I call using the URL it does use the PUIMAPP table and call the correct program. I can directly read the JSON output (returned environment pointer and data), but the user and LIBL are lost to my RPG program. I had to hardcode the path to the display file in the RPG to get it to work. I could pass parameters and re-create the authorities and LIBL, but am hoping that there is a link or method to use the so that I do not need to go to the user profile and recreate everything for each AJAX call. I think I just do not know how the universal file knows the userid and LIBL. Is it that simple?
The sequence is:
1. The User has already signed on
2. At the on-load event for the initial program we want to retrieve the list of programs for the user.
We create our own display/filters/sorts/ and custom component displayed in a content pane.
The RPG program will be available when the on-load is complete but is moved off the screen so that it is in effect hidden to the user.
3. When the user selects a menu option it will be forwarded to the hidden RPG screen for processing. This preserves the existing RPG edits and processing we already use. In effect we are just replacing the display content and adding sort/filter functionality to the display portion.
Management has outlined client side functionality that I believe to be well into your option 3, the ajaxJSON routine to retrieve and display content. I have read the ajaxJSON example referenced and it does read and write to the environment and works fine except that there is no user or library list associated with it. The example is in fact what I based my initial work on. The the crux of the issue is still that I would like to have the user and libl without having to generate it each time I do an ajax call via a URL. Is this related to the AUTH=xxxxx parameter? That appears to be a profound parameter for a URL call, It seems hopeful at this point.
Current thoughts for approach
Here is what I am looking at. In the URL string to a universal display file there is the ability to map and design values into the JSON string. If I call using the URL it does use the PUIMAPP table and call the correct program. I can directly read the JSON output (returned environment pointer and data), but the user and LIBL are lost to my RPG program. I had to hardcode the path to the display file in the RPG to get it to work. I could pass parameters and re-create the authorities and LIBL, but am hoping that there is a link or method to use the so that I do not need to go to the user profile and recreate everything for each AJAX call. I think I just do not know how the universal file knows the userid and LIBL. Is it that simple?
-
- 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: Setup for JSON using a Universal Display File.
The pui["appJob"]["auth"] variable contains your Rich Display session ID. If you pass that in an AUTH= query string parameter, the Universal session controller will automatically syncrhonize the userid & library list with the userid/libl of the Rich Display program you are calling it from. (I should note that we did discover a bug in this support in that it doesn't add the PROFOUNDUI library into the library list unless that's already in the Rich Display library list -- this will be fixed in the next release of Profound UI)
You do that by coding something like this when building your URL, assuming you are doing it in JavaScript:
(Of course, if this isn't the first parameter in the URL, you'd use & instead of ? -- I'm guessing you know that part.)
Or if you are doing this inside a property for a widget, you'd do it slightly differently. If you start a property name (including the 'ajax url' property for the ajax container) with script:, Profound UI will run it as JavaScript and take the output of the script as the property value. So you'd set the 'ajax url' property like this:
The URL parameters for most Profound UI widgets will automatically add the AUTH -- but not the AJAX container or the AJAX APIs, if you use those, you need to add it by hand.
You do that by coding something like this when building your URL, assuming you are doing it in JavaScript:
Code: Select all
url += "?AUTH=" + pui["appJob"]["auth"]
Or if you are doing this inside a property for a widget, you'd do it slightly differently. If you start a property name (including the 'ajax url' property for the ajax container) with script:, Profound UI will run it as JavaScript and take the output of the script as the property value. So you'd set the 'ajax url' property like this:
Code: Select all
script: "/profoundui/universal/yourpgm?AUTH=" + pui["appJob"]["auth"]
-
- 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: Setup for JSON using a Universal Display File.
I don't understand why your initial program doesn't simply load the list of programs onto the screen before displaying it. By that I mean, have RPG code that gets the list of programs and puts them into a variable (or multiple variables, depending on how you want to display them) so that they'll be displayed when the EXFMT occurs?
Why go through the extra work and complexity of making an AJAX call from your onload instead of doing it in the RPG code to begin with?
Why go through the extra work and complexity of making an AJAX call from your onload instead of doing it in the RPG code to begin with?
-
- New User
- Posts: 7
- Joined: Tue Jan 13, 2015 11:00 pm
- First Name: Todd
- Last Name: Cameron
- Company Name: Blood Bank Computer Systems
- Address 1: 1002 15th St SW
- City: Auburn
- State / Province: Washington
- Zip / Postal Code: 98001
- Country: United States
- Contact:
Re: Setup for JSON using a Universal Display File.
Thanks Scott - I will report my findings to the forum but I think your last reply with the AUTH settings has this particular issue covered.
Whether you know it or not, you have given me a couple of other good thoughts along the lines of default settings, bindings, and some other things I have noticed in the code snippets.
The reason we make the AJAX call is that we still use the RPG on green screen with a different display. I agree with you that this is pretty silly and expect that I will be changing this shortly, as soon as I get the first issue resolved. Thanks for the nudge that direction...Why go through the extra work and complexity of making an AJAX call from your onload instead of doing it in the RPG code to begin with?
Whether you know it or not, you have given me a couple of other good thoughts along the lines of default settings, bindings, and some other things I have noticed in the code snippets.
Who is online
Users browsing this forum: No registered users and 1 guest