VLF-ONE Contextual Error Messages

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 Contextual Error Messages

Post by jyoung »

Is there any way to have contextual error messages with VLF-ONE?

xDemoWebContextualMessages shows how you can use contextual messages to show validation issues to the user. I would like to be able to do something similar.

VLF's avIssueMessage does not seem to nightlight or put some indicator on the control itself which is what I want. I tried using SYS_MSGQ but nothing seems to happen when a message is added.

My use case is that we have a "Notes" that consist of 5 separate fields (Line1 - Line5) in a File. I created a work field to use a Multi-Line edit box ( a simple control will not get hooked up into the PRIM_EVP collection) and then collapse those lines into a single value and set the work field to that value.

Since the work field is a free format text field, its length must be constrained by the sum of the lengths of the line fields. When the user puts in text that exceeds that length, I want to "highlight" that error in the same way that the above mentioned contextual errors do.
MarkD
Posts: 692
Joined: Wed Dec 02, 2015 9:56 am

Re: VLF-ONE Contextual Error Messages

Post by MarkD »

Yous should be able to do this, and there may be several ways, but first a question ...........

Do you have an #AVFRAMEWORKMANAGER.avReceiveSystemMessageQueue method invocation in your code?
MarkD
Posts: 692
Joined: Wed Dec 02, 2015 9:56 am

Re: VLF-ONE Contextual Error Messages

Post by MarkD »

I am assuming you want the message text to display in the status area of the command handler pane?

If yes, then attached is an updated version of reusable part DF_T42H1O, the shipped Business Object 101 example command handler.

If you import it to replace DF_T42H1O and recompile it then it should demonstrate what you want to do.

It now has a new method PerformLocalValidation that attempts some local validations before attempting to save on the server.

It shows how to get the red attention marks in a VLF command handler:
Capture1.PNG
Capture1.PNG (18.7 KiB) Viewed 11844 times
Attachments
QuickExport20170313163855.zip
(15.06 KiB) Downloaded 1115 times
MarkD
Posts: 692
Joined: Wed Dec 02, 2015 9:56 am

Re: VLF-ONE Contextual Error Messages

Post by MarkD »

If you want to go for something much less subtle then try this version which highlights the error fields with a yellow fluro highlighter ........
Capture2.PNG
Capture2.PNG (19.1 KiB) Viewed 11843 times
Attachments
QuickExport20170313170607.zip
(15.19 KiB) Downloaded 1147 times
jyoung
Posts: 694
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: VLF-ONE Contextual Error Messages

Post by jyoung »

Hi Mark,

Thanks for the samples.

I do have the avReceiveMessageQueue at the top of my SaveDataService.Completed event routine.

Should the messages work with MultLine Edit Boxes?

I added an Edit Control (#Edit1) along with my Notes work field (#wk_Notes, a multiline edit visual host) and a plain MultiLine Edit Box (#Text1). I add a message for all three of these and only the #Edit1 indicator shows up.
Capture.PNG
Capture.PNG (16.56 KiB) Viewed 11836 times

Code: Select all

mthroutine name(Save)

* define the data service
define_com class(#CMGCCPServerModule.SaveDetails) name(#save)

#SYS_MSGQ.Add( "Error 1" #Edit1 )
#SYS_MSGQ.Add( "Error 2" #wk_Notes )
#SYS_MSGQ.Add( "Error 3" #Text1 )
return
* other stuff omitted
endroutine
For some reason the indicators do not turn on for MultiLine EditBoxes.
MarkD
Posts: 692
Joined: Wed Dec 02, 2015 9:56 am

Re: VLF-ONE Contextual Error Messages

Post by MarkD »

avReceiveMessageQueue routes all messages from #SYS_MSGQ into the message display area at the bottom of the command handler pane.
Then it clears #SYS_MSGQ, which is the critical operation with regard to the red error exclamation marks because because that removes them all from the display. That is is why the first example did not use avReceiveMessageQueue when generating local messages.
MarkD
Posts: 692
Joined: Wed Dec 02, 2015 9:56 am

Re: VLF-ONE Contextual Error Messages

Post by MarkD »

I don't think you can apply the red exclamation mark error indication to labels or to multi line edit boxes.
My suggestion would be to create a distinctive error style and use it like this example:

Code: Select all

Begin_Com Role(*EXTENDS #PRIM_WEB)

Define_Com Class(#Prim_vs.SolidBrush) Name(#ErrorBackground) Color(255:233:157)
Define_Com Class(#Prim_vs.Style) Name(#ErrorStyle) Backgroundbrush(#ErrorBackground)

Define_Com Class(#xEmployeeSurname.Visual) Name(#UseSurname) Displayposition(1) Left(23) Parent(#COM_OWNER) Tabposition(1) Top(112)
Define_Com Class(#PRIM_LABL) Name(#TestLabel) Caption('Label1') Displayposition(2) Ellipses(Word) Height(25) Left(24) Parent(#COM_OWNER) Tabposition(2) Tabstop(False) Top(176) Verticalalignment(Center) Width(505)
Define_Com Class(#PRIM_TEXT) Name(#TestMultiLineText) Displayposition(3) Left(24) Parent(#COM_OWNER) Tabposition(3) Top(232) Width(569) Height(145)

Define_Com Class(#Prim_phbn) Name(#ApplyErrors) Caption('Apply Errors') Parent(#COM_OWNER) Displayposition(5) Tabposition(5) Width(215)

Define_Com Class(#Prim_phbn) Name(#RemoveErrors) Caption('Remove Errors') Parent(#COM_OWNER) Displayposition(4) Tabposition(4) Width(215) Left(256)

Define_Com Class(#Prim_vs.Style) Name(#SaveBasicVisualStyle) Reference(*DYNAMIC)

* -------------------------------------------------------------------------
Evtroutine Handling(#com_owner.CreateInstance)

#SaveBasicVisualStyle <= #UseSurname.Style

#UseSurname.Value := "Fred Bloggs"

Endroutine

* -------------------------------------------------------------------------
Evtroutine Handling(#ApplyErrors.click)

* Reset everyone to default styles
#UseSurname.editstyle <= #SaveBasicVisualStyle
#TestLabel.Styles.Remove Style(#ErrorStyle)
#TestMultiLineText.Styles.Remove Style(#ErrorStyle)

* Apply error styles as if everything is in error
#UseSurname.editstyle <= #ErrorStyle
#TestLabel.Styles.add Style(#ErrorStyle)
#TestMultiLineText.Styles.add Style(#ErrorStyle)

Endroutine

* -------------------------------------------------------------------------
Evtroutine Handling(#RemoveErrors.click)

* Reset everyone to default styles
#UseSurname.editstyle <= #SaveBasicVisualStyle
#TestLabel.Styles.Remove Style(#ErrorStyle)
#TestMultiLineText.Styles.Remove Style(#ErrorStyle)

Endroutine

End_Com   
Ultimately, this is really just a variation of the second DF_T42H1O example provided.

BTW - this is a good case for creating a VLF-ONE custom framework manager because it would allow you to centrally define the error style.
error.png
error.png (15.76 KiB) Viewed 11823 times
Mkolbe
Posts: 27
Joined: Tue Apr 04, 2017 12:45 am

Re: VLF-ONE Contextual Error Messages

Post by Mkolbe »

I wonder if MarkD's statement about the limitations of the red exclamation mark error indicator also applies to DropDownLists?
I was unable to get the exclamation mark to appear for my Status Field (DropDownList) using #SYS_MSGQ.Add( 'Status must be entered' #OC01_Status ).
I had to apply an error style instead.
Error indicators.PNG
Error indicators.PNG (19.13 KiB) Viewed 11731 times
Post Reply