Page 1 of 1
(RDMLX) Testing for Signature (Online)
Posted: Thu Mar 20, 2014 6:19 am
by MarcusLancaster
Hi all.
I'm testing to see if a signature has been entered via an ONLINE form - basically I don't want processing to save changes unless the user has included a signature. So I found that the shipped example LREX0093 looked to be doing something very similar to what I need, and I therefore included a test of this value;
#Com_owner.CheckProperty( '/Form.fields.PANL_MIDDLE.fields.IMGE_SIGNATURE.Annotation.Image' )
But it is always FALSE, regardless of whether there is any annotation or not.
I must be doing something wrong - has anybody got an example where you are checking that some annotation has been made to an image?
Cheers.
Marcus.
Re: Testing for Signature (Online)
Posted: Thu Mar 20, 2014 9:25 am
by Mark_Dale
Hi Marcus,
The trick with image modifications is that they only come down to the server once, so you have to try and save changes every time the server side runs.
The other trick might be what type of image merging is being used. - Note this comment in the example:
* Annotate_Mergewthimg (Annotate_Merge_with_Image) = False in this example. So any annotations are returned in .Annotation.Image.
The LREX0093 example does have a check for when the signature has been added. I modfied it to put in some trace statements.
(The #uStatus field is a boolean field)
mthroutine uSave_Signature
#Com_Owner.AppTraceOn
#Com_Owner.AppTrace Text('Action is:' + #Com_Owner.RequestACTION)
* This routine has to occur every cycle (every time control returns to the server), even if the user does not press the save button or the submit command, because the client side will not send the image down to the server if it is unchanged from what was received from the server.
* Annotate_Mergewthimg (Annotate_Merge_with_Image) = False in this example. So any annotations are returned in .Annotation.Image.
* Has an annotation image been added to the Image, or modified, this cycle?
#uStatus := #Com_owner.CheckProperty( '/Form.Fields.IMAGE_1_ELEMENT.Annotation.Image' )
If (#uStatus)
* There is an annotation - save it as a separate image
#Com_Owner.Save_Annotation Name(IMAGE_1_ELEMENT) Filename(#uImageFile)
Endif
#Com_Owner.AppTrace Text('#uStatus is:' + #uStatus.AsString)
#Com_Owner.AppTraceOff
endroutine
And the trace does reflect whether the signature was modified:
LANSA/IBMi/V12-2014-03-19-22:13:55:857 Action is:SUBMIT
LANSA/IBMi/V12-2014-03-19-22:13:55:862 #uStatus is:True
LANSA/IBMi/V12-2014-03-19-22:13:55:863 Application tracing ended
LANSA/IBMi/V12-2014-03-19-22:16:33:265 Application tracing started
LANSA/IBMi/V12-2014-03-19-22:16:33:265 Action is:SUBMIT
LANSA/IBMi/V12-2014-03-19-22:16:33:266 #uStatus is:False
LANSA/IBMi/V12-2014-03-19-22:16:33:267 Application tracing ended
Re: Testing for Signature (Online)
Posted: Thu Mar 20, 2014 6:02 pm
by MarcusLancaster
Cheers for that Mark.
I'll dig into this today... and will post findings back to the forum...
Cheers.
Marcus
Re: Testing for Signature (Online)
Posted: Fri Mar 21, 2014 3:30 am
by MarcusLancaster
Hi all.
Further to this - I've worked out what the problem is.
This code;
#Com_owner.CheckProperty( '/Form.Fields.IMAGE_1_ELEMENT.Annotation.Image' )
does return TRUE if an annotation has been made, and FALSE if it hasn't. My dodgy code I'm afraid, so thanks Mark for the sample code!
However... if I use this;
Annotate_Showbutton(true)
to allow the user to tap the image and Clear the annotation... even though the signature has gone, the CheckProperty still returns TRUE. So in my situation it is possible for the user to bypass my validation by entering a signature, clearing it and then pressing the save button.
When I was doing similar logic in "offline" mode I solved this a different way - the signature was stored in a local database table on the client device and I was able to test that field's "length" - if it was zero the annotation was missing.
So I'm still looking for a way to test the annotation's existence, size etc.
Cheers for now.
Marcus.
Re: Testing for Signature (Online)
Posted: Fri Mar 21, 2014 9:48 am
by MarkDuignan
The question is whether an 'empty' signature is a signature - compared to, say, a single dot?
Can you try this out?
The annotation save returns a numeric return code:
#ReturnCode = Com_Owner.Save_Annotation Name(IMAGE_1_ELEMENT) Filename(#uImageFile)
1 means the property was found and a file of 1 or more bytes was successfully saved.
-10 means that the property was not found - so no file was saved (that should match with a check property of false).
-30 means that the property was found but it was null or had a zero data length – so no file was saved.
Any other value means that the property was found - but that the file save failed (eg: I/O error). The file may or may not
have been fully or partially saved.
So if the property check says true (property found) and the save returns -30 – then you should have an empty or null signature.
You might also be able to get rid of the check property?
If you try the save on every operation then getting a -10 tells you the same thing - and the performance hit would be exactly the same.
Note: There is no documentation of these error codes. Use this forum to get such fine details.
Re: Testing for Signature (Online)
Posted: Fri Mar 21, 2014 8:57 pm
by MarcusLancaster
Hi Mark,
Exactly what I need
Thanks for the info on those codes - yep works as you suggest.
And yes, they could just enter a dot as a signature... its a difficult one... but really we're aiming to prompt them to enter something.
Cheers.
Marcus.