Page 1 of 1

Dynamic Auto-Complete and webservice

Posted: Fri Feb 12, 2016 4:02 am
by guillaume.frery
Hello;
First of all, I want to say that I am a new visual designer user and I am only a RGP developper.

I want to use Dynamic Auto-complete with a rest webservice, calling an RPG program.
I have deploy my RPG program as a REST webservice.

I have put the URL in the Choice URL of the textbox.
2016-02-12_08h43_50.png
2016-02-12_08h43_50.png (21.61 KiB) Viewed 2386 times

When I call my URL, the webserbice sends some data.
2016-02-12_08h48_36.png
2016-02-12_08h48_36.png (50.09 KiB) Viewed 2386 times

When I call the program, it looks like the webservice isn't call. When I debugg with firedebug, I have this message :
2016-02-12_09h00_12.png
2016-02-12_09h00_12.png (161.74 KiB) Viewed 2386 times
It is as if the webservice was call with an authentification.
Is it a problem with my webservice server or is there something wrong with the way I try to do this?

Thank you
Guillaume

Re: Dynamic Auto-Complete and webservice

Posted: Fri Feb 12, 2016 9:33 pm
by Scott Klement
Hello,

I see a few problems:

1) You are not passing the full URL.

On the one that you show working, the URL is
http://as400dev:10021/web/services/ws_articl2/baignoire

In Profound UI, the URL is:
http://as400dev:10021/web/services/ws_articl2/

Since this last URL is missing the 'baignoire' portion of the URL, you get a 404 not found error.


2) JSON data is case-sensitive.

Your properties ("success", "response", "results", etc) are in all uppercase, but Profound UI is expecting them to be in lowercase.


3) Web browsers typically only allow you to send requests to the same HTTP server that sent the page you're on. Sending/receiving from another domain creates a "cross-domain" request, which browsers will often block for security reasons. To avoid this you must use the same server & port number for the web service as you do for the Profound UI page, or use a workaround like a proxy.


If I were you, I would consider using Profound's UNIVERSAL handler or similar for this web service instead of IBM's IWS. But, of course, that's up to you.

Re: Dynamic Auto-Complete and webservice

Posted: Mon Feb 15, 2016 6:19 am
by guillaume.frery
Hello Scott;
Thank you for your answer.
First, I don't pass the full URL, because the end of the URL (baignoire) is the search argument, corresponding to the auto-complete text.

I didn't know there is a profound's universal handler for the webservices. I will try to make a look on the forum to see if there are exemples to do what I want.
Best regards

Re: Dynamic Auto-Complete and webservice

Posted: Mon Feb 15, 2016 3:48 pm
by Scott Klement
guillaume.frery wrote:First, I don't pass the full URL, because the end of the URL (baignoire) is the search argument, corresponding to the auto-complete text.
Profound UI isn't going to automatically add the search term on to the URL, so if you want to use a web service like this one, you'll need to add the search term onto the URL yourself, possibly by calling an RPG program that calls the web service, or maybe with URL rewriting in Apache (I'm not completely sure if URL rewriting will work, but it might be worth looking into.)

Re: Dynamic Auto-Complete and webservice

Posted: Tue Feb 16, 2016 3:33 am
by guillaume.frery
Scott;
Thank you for this information.
I am trying to do the auto-complete on the text box, with the RPG program, but I have another issue.
On the 'onkeyup' properties, I have put the pui.click(); javascript, so my RPG program can run. The RPG, is calling the webservice which will return data selection for the text box. I put this data in 2 fields, with comma separators, and I have attache this fields on the auto-complete of the text box.
2016-02-16_08h17_39.png
When I run the RGP, I have a program message
2016-02-16_08h23_21.png
Do you have an idea for this issue?
Thanks a lot
Guillaume

I have found my issue !
It was a problem in the webservice : the program was doing a RCLRSC.
I apologise for the inconvenience.

Re: Dynamic Auto-Complete and webservice

Posted: Fri Apr 15, 2016 6:52 am
by ZoeW
*edit*

After writing a post about how I couldn't get auto-complete to work with a dynamic URL, it worked... I think this is due installing 5.4.

I was able to achieve it by creating the URL as part of the on-blur event of the element (selToWhs) which precedes the one I wanted auto-complete to work on (selToLoc).

On-blur event of selToWhs:

E.g.

Code: Select all

myURL = http://systemi:8080/profoundui/universal/whsUtils?REQTYPE=*LOCSAUTO&QWHS=" + get("selToWhs").substring(0, 2) + "&QPRD=" + get("selprod")

applyProperty("selToLoc", "choices url", myURL);
applyProperty("selToLoc", "field type", "textbox");

The resulting URL for 'choices url' is then "http://systemi:8080/profoundui/universa ... &QPRD=BDGK", when I look at the HTTP POST I see this as the URL and 'query' as the post data.

We are using Universal Display with an RPG program (as defined in PUIMAPP), the RPG uses QWHS, QPRD and query to return a list of values for auto-complete.

Zoe

Re: Dynamic Auto-Complete and webservice

Posted: Fri Apr 15, 2016 10:48 am
by Glenn
Zoe,

URLs have rules on how special characters (spaces, question marks, etc.) should be encoded so, to avoid possible future issues where your 'selToWhs' or 'selprod' data might contain them, you might want to URI encode the URL. I would do something like below (Note that I haven't tested this...).

Code: Select all

myURL = http://systemi:8080/profoundui/universal/whsUtils?REQTYPE=*LOCSAUTO" 
myURL += "&QWHS=" + encodeURIComponent(get("selToWhs").substring(0, 2));
myURL += "&QPRD=" + encodeURIComponent(get("selprod"));
More info here:
http://www.w3schools.com/jsref/jsref_en ... ponent.asp

Glenn

Re: Dynamic Auto-Complete and webservice

Posted: Mon Apr 18, 2016 9:43 am
by ZoeW
Many thanks Glenn, I'll add that to my code.