SignaturePad works intermittently

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
k2R400
Profound User
Posts: 62
Joined: Sat Feb 18, 2012 12:03 pm
First Name: Patrick
Last Name: THOMAS
Company Name: Oo2
Country: France
Contact:

SignaturePad works intermittently

Post by k2R400 »

Hello,

I have a SignaturPad and a button with the code below:

Code: Select all

const obj = JSON.parse('{ "signaturePadId": "SignaturePad", "dir": "/tmp", "imageType": "image/png", "fileName": "SaMQDE5CfdfvfJC6rkqf.png ", "overwrite": true }');
pui.uploadSignature(obj);
pui.click();
The file is saved in /tmp but only every other time ...
The RPGLE program that calls this screen has a simple EXFMT and ends with * INLR = * on
One time it works, then a second time no, no file is generated in the IFS, any idea why?
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: SignaturePad works intermittently

Post by Scott Klement »

I feel like there may be a timing issue, here.

You run pui.uploadSignature() -- which causes an upload to run in the background. How long that upload takes will depend on the size of the signature, the speed of the network, how fast the server is able to respond, and several other things, so there's no easy way to tell how long it'll take.

Meanwhile, you run pui.click(). This will submit all of the screen data back to your RPG program, causing it to do processing, etc. When its done, it will send another screen, which will destroy the current screen (including the upload running in the background) and draw a new one.

So, it seems to me that doing a pui.uploadSignature() followed immediately by pui.click() would cause a "timing problem". Sometimes it may work, sometimes it may not. It'd depend on which network request finishes first.
k2R400
Profound User
Posts: 62
Joined: Sat Feb 18, 2012 12:03 pm
First Name: Patrick
Last Name: THOMAS
Company Name: Oo2
Country: France
Contact:

Re: SignaturePad works intermittently

Post by k2R400 »

Thanks Scott.
So what is the solution?
Maybe using the handler?
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: SignaturePad works intermittently

Post by Scott Klement »

Right, do the pui.click() in the handler so you know it has completed.
k2R400
Profound User
Posts: 62
Joined: Sat Feb 18, 2012 12:03 pm
First Name: Patrick
Last Name: THOMAS
Company Name: Oo2
Country: France
Contact:

Re: SignaturePad works intermittently

Post by k2R400 »

Thanks Scott.
But in my example at the beginning of this post, with a JSON.PARSE, how to code the call to the handler.
must admit that I have a little trouble with JS

TY
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: SignaturePad works intermittently

Post by Scott Klement »

Can you explain why you are doing the JSON.parse? since the code you are parsing is hard-coded right there on the screen, it seems to me that you are just adding extra work for yourself vs. just coding the js object. Why use json parse?

But, even so, you could just add the handler to the obj after the parse, so I don't really see the problem.

1. change from 'const' to 'var' so that it is not constant, i.e. you can make changes to it.
2. after the parse, do obj.handler = function() { pui.click() }
k2R400
Profound User
Posts: 62
Joined: Sat Feb 18, 2012 12:03 pm
First Name: Patrick
Last Name: THOMAS
Company Name: Oo2
Country: France
Contact:

Re: SignaturePad works intermittently

Post by k2R400 »

Thanks a lot !
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest