Hello everybody,
a customer of us has following request:
- when working web pages we use server modules for saving data
- when errors occur they are available in SYS_MSGQ and the messages are shown in a message popup component.
So far , so good – but now they want to know exactly which fields are not okay and to change the display style of these fields in the web page.
Can we realize this somehow? How do we get the information which fields are not correct from the servermodule / OAM?
Best regards and many thanks in advance,
Joerg
Webpage Error Messages / Field Display
-
Joerg Hamacher
- Posts: 120
- Joined: Thu Feb 11, 2016 12:01 am
- Stewart Marshall
- Posts: 417
- Joined: Thu Nov 05, 2015 5:25 pm
Re: Webpage Error Messages / Field Display
Hi Joerg
At the moment, this functionality isn't available with OAM errors/messages. In fact, there has never been a direct coding level link between fields and messages. However, this is something that is in the pipeline.
In the meantime, have a look at xDemoWebContextualMessages. This uses locally coded validation, but I think it will provide the customer with the solution they're looking for.
At the moment, this functionality isn't available with OAM errors/messages. In fact, there has never been a direct coding level link between fields and messages. However, this is something that is in the pipeline.
In the meantime, have a look at xDemoWebContextualMessages. This uses locally coded validation, but I think it will provide the customer with the solution they're looking for.
Re: Webpage Error Messages / Field Display
I ran into the same issue recently and I was able to implement a workaround. Its not perfect, but it seems to be working ok so far. Its for VLF-ONE, but it should be expandable to any web page.
The problem is that when the response from the server comes back, there is no reference to the control (field) that caused the message in the Message Queue. So my solution was to include the field name in the message text. This means we can't use message files, but I am ok with that.
Here is a rule for a field that has the control name specified in the message. Now we need to collect all the fields on the page. I am using a Keyed Collection so that I can refer to the control by name.
That method gets called in the the initialize routine.
Then after the call to the server, I call this method to highlight errors.
You can see that I just parse the name out of the message and use the control collection to get a reference to the problem control.
Also have a custom Error style defined
Now when a field is in error it looks like
I can clear the errors by this method.
Like I said, its not perfect, but its working out ok so far.
Joe
The problem is that when the response from the server comes back, there is no reference to the control (field) that caused the message in the Message Queue. So my solution was to include the field name in the message text. This means we can't use message files, but I am ok with that.
Here is a rule for a field that has the control name specified in the message. Now we need to collect all the fields on the page. I am using a Keyed Collection so that I can refer to the control by name.
Code: Select all
define_com class(#PRIM_KCOL<#PRIM_EVP #STD_STRNG>) name(#PanelFields) style(Collection)
mthroutine name(CollectEditableControls)
define_map for(*INPUT) class(#PRIM_PCOL<#PRIM_CTRL>) name(#controls) pass(*BY_REFERENCE)
define_com class(#PRIM_EVP) name(#tempField) reference(*DYNAMIC)
define_com class(#PRIM_CPST) name(#tempContainer) reference(*DYNAMIC)
for each(#control) in(#controls)
if_ref com(#control) is(*INSTANCE_OF #PRIM_EVP)
#tempField <= #control *As #PRIM_EVP
#PanelFields<#tempField.Name> <= #tempField
else
if_ref com(#control) is(*INSTANCE_OF #PRIM_CPST)
#tempContainer <= #control *As #PRIM_CPST
#COM_OWNER.CollectEditableControls( #tempContainer.ComponentControls )
endif
endif
endfor
endroutine
Code: Select all
#COM_OWNER.CollectEditableControls( #COM_OWNER.ComponentControls )
Code: Select all
mthroutine name(HighlightProblems)
define_map for(*INPUT) class(#PRIM_KCOL<#PRIM_EVP #STD_STRNG>) name(#fields) pass(*BY_REFERENCE)
define field(#control) type(*STRING)
define field(#errorMessage) type(*STRING)
define field(#separatorIndex) type(*INT)
#avFrameworkManager.avRecordTrace component(#COM_OWNER) event("Highlighting Problems")
#avFrameworkManager.avRecordTrace component(#COM_OWNER) event(("&1 Messages In Queue").Substitute( #SYS_MSGQ.Messages.ItemCount.AsString ))
for each(#message) in(#SYS_MSGQ.Messages)
if (#message.Text.Contains( ":" ))
#separatorIndex := #message.Text.LastPositionOf( ":" )
#control := #message.Text.Substring( 1 (#separatorIndex - 1) )
#errorMessage := #message.Text.Substring( (#separatorIndex + 1) #message.Text.CurChars )
#avFrameworkManager.avRecordTrace component(#COM_OWNER) event(("Message for Control: &1 Message: &2").Substitute( #control #errorMessage ))
if (#fields<#control> *IsNot *NULL)
#fields<#control>.Styles.Add( #Error )
#SYS_MSGQ.Add control(#fields<#control>) text(#errorMessage)
endif
else
* even though we don't have a seperator, we should still display the message
#avFrameworkManager.avIssueMessage text(#message.Text) requester(#COM_OWNER) tomainform(False) clearexistingmessages(False)
endif
endfor
endroutine
Also have a custom Error style defined
Code: Select all
define_com class(#PRIM_VS.Style) name(#Error) backgroundbrush(#Brush2) borderbottom(1) borderbrush(#Brush3) borderleft(1) borderright(1) bordertop(1) foregroundbrush(#Brush4)
define_com class(#PRIM_VS.SolidBrush) name(#Brush4) color(255:8:2)
define_com class(#PRIM_VS.SolidBrush) name(#Brush3) color(255:6:0)
define_com class(#PRIM_VS.SolidBrush) name(#Brush2) color(255:215:215)
Code: Select all
mthroutine name(ClearProblemHighlights)
define_map for(*INPUT) class(#PRIM_KCOL<#PRIM_EVP #STD_STRNG>) name(#fields) pass(*BY_REFERENCE)
#avFrameworkManager.avRecordTrace component(#COM_OWNER) event("Clearing Problem Hightlights")
for each(#field) in(#fields)
#field.Styles.Remove( #Error )
endfor
#avFrameworkManager.avClearMessages requester(#COM_OWNER)
* this may be redundant
#SYS_MSGQ.ClearAll
endroutine
Joe