VLF-ONE Client Side Repository Validation

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
jyoung
Posts: 694
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

VLF-ONE Client Side Repository Validation

Post by jyoung »

Ok, so in SP2 I have heard that Repository Validation now works on VLWeb client fields. Spinning up one of the new SP2 demo templates show this.
error capture.PNG
error capture.PNG (15.92 KiB) Viewed 8672 times
This does not seem to work in VLF-ONE as the control does not get highlighted. Only the message appears.
vlf-one error capture.PNG
vlf-one error capture.PNG (12.47 KiB) Viewed 8672 times
When trying to figure out why, I discover on the VLWeb template, there is a "Validate" method on Dialogs and Views.

Code: Select all

evtroutine handling(#SaveIcon.Click)
if (#COM_OWNER.Validate( Update #xContacts ))
#COM_OWNER.Save
endif
endroutine
There is no such method on the VF_AC010O object, but there are some avValidate methods
track control changes.PNG
track control changes.PNG (9.3 KiB) Viewed 8672 times
I can't find any documentation on these.

Are these used to perform client side validation like in VLWeb's Dialog and View?
How do you use them?
Can client side repository validation be done in VLF-ONE or are we stuck doing it the old way. viewtopic.php?f=3&t=193&p=2388

EDIT
I've been experimenting with the avValidate methods but not getting expected results.
I track the controls in the uInitialize

Code: Select all


mthroutine name(uInitialize) options(*REDEFINE)
* Do any initialization defined in the ancestor
#COM_ANCESTOR.uInitialize

#ASCSRHObjectManager.Register command(#COM_OWNER)

* Build collection of Editable fields
#COM_OWNER.CollectEditableControls( #COM_OWNER.ComponentControls )

#COM_OWNER.avTrackControlChanges incontainer(#ContainerPanel)

#SaveButton.Enabled := False
endroutine
And on the button click

Code: Select all

evtroutine handling(#SaveButton.Click)
if (#COM_OWNER.avValidateAllTrackedMDControls( UPDATE ))
#COM_OWNER.avQueueAsyncOperation busystatetext('Saving') operationid(SAVE)
endif
endroutine
But the avValidateAllTrackedMDControls always returns true. A difference from this method and the VLWeb method is that this method does not include the Table, which should be required as far as I know.
MarkD
Posts: 692
Joined: Wed Dec 02, 2015 9:56 am

Re: VLF-ONE Client Side Repository Validation

Post by MarkD »

Those new methods are designed to work in conjunction with the code that the VLF generates from the Common Activities tab. I think that the best way to see how they work would be to use a test framework. Create a business object, then use its Common Activities tab to generate an automatic SCRUD ………….

Capture.PNG
Capture.PNG (37.16 KiB) Viewed 8659 times
Check the MD style control option, then define the instance list columns and associate the business object with a data base table (eg: xEmployee) then generate a simple SCRUD.

That will create a hidden filter and a command handler.

The SCRUD command handler shows how the client side validation methods you are interested in are used.

A key one of interest is the redefined method avHandleTrackedControlChange which executes every time a control that is being tracked/monitored is changed. It clears any errors. Another is avValidateTrackedMDControl which validates a control, and also scrolls it into view if it has an error.

Those methods are just very specialized VLF-ONE abstractions to make doing client side validation use less code.

You don’t need to use them, and it may be better not to.

It’s important to remember that at the lowest level, if you have a control like:

Define_Com Class(#xEmployeeGivenNames.EditField) Parent(#DataItemPanel)

Then you can use these in any way you like:

#xEmployeeGivenNames.ClearError

#isValid := #xEmployeeGivenNames.Validate( Insert #xEmployee ) /* Say */

If you have your form elements in some sort of a collection, or as iterable children of a container like a view or a panel, then you can do this in a loop using less code.

I think (but am not sure) that not specifying a table name might also be valid, because it would apply any dictionary level validation rules that apply to the field globally, rather than just database table:

#isValid := #xEmployeeGivenNames.Validate( Insert )
MarkD
Posts: 692
Joined: Wed Dec 02, 2015 9:56 am

Re: VLF-ONE Client Side Repository Validation

Post by MarkD »

There's also hotfix related to this area.
This prevents the SCRUD generator from using the wrong table name for validation - but it's very easy to correct manually if you don't have the hotfix installed.
viewtopic.php?f=4&t=1829
jyoung
Posts: 694
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: VLF-ONE Client Side Repository Validation

Post by jyoung »

Hi Mark,

Thanks for the help, I never would have anticipated having to redefine multiple methods and invoke the validation on the control itself.
VLWeb seems to make it much easier.

It appears that this does not support lookups and complex logic checks as those checks don't get the same UI highlighting treatment.

Joe
dannyoorburg
Posts: 177
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

Re: VLF-ONE Client Side Repository Validation

Post by dannyoorburg »

Hi Joe,

you're right, it doesn't support lookups and complex logic checks (at least, currently it doesn't).

It only supports checks that CAN actually be performed on the client using only information that is at that point in time available on the client.

Since lookups involve database access and complex logic checks COULD involve database access, they HAVE to run on the server.

I understand that we like the reporting mechanism, the material design error state/error message, and that we would love to see those server side checks being reported in the exact same way as the client side checks. We're just not there currently, as we're still missing the correct context in messages coming back from the server.

Having said that, I do find that a lot of the additional server side messages don't really have a single context and in that sense don't really belong on a single field but might much be better off on an alert.

Cheers,
Danny
Post Reply