cancel
Showing results for 
Search instead for 
Did you mean: 

How to clear a ContextAttributeMessage?

Former Member
0 Kudos

Hello all,

If I am using the following to display an attribute message to the user:

wdComponentAPI.getMessageManager().reportContextAttributeMessage(myelement,attrinfo,myWDMessage,null,true);

How can I remove this message once my validation is satisfied? There are no button clicks involved, the validation is done everytime the user changes an input field, so it is necessary to report/remove this message myself.

Any ideas?

Thanks,

-Kevin

Accepted Solutions (0)

Answers (1)

Answers (1)

lajitha_menon
Contributor
0 Kudos

Hi Kevin,

It is not possible to trace whether an input field has been changed, unless an action is trigerred. That could be either clicking on Enter(link to the onEnter action of that input field), or when the user clicks on a button. So, You would have to write the validation on one of these actions, and then give the message.

Regards,

LM

Former Member
0 Kudos

Hi LM,

We use a calcualted attribute which allows us to validate without Enter or button click. But the issue we have has to do with the attribute message. We need to find a way to remove an attribute message. I believe in Web Dynpro for ABAP there is a way to do this, but we do not know how this can be done in Web Dynpro for Java.

Thanks,

-Kevin

lajitha_menon
Contributor
0 Kudos

Hi there,

I havent used these context attribute exception messages, but will it not disappear automatically when the screen is refreshed? i.e, you validate a field and raise the exception. Next time it gets to the same code, it should not raise that exception if the input is valid -right? Are you saying that the message is staying there in spite of the input being valid?

regs,

lm

PS:

You can check whether the message manager has exceptions by using methods like

if(wdComponentAPI.getMessageManager().hasExceptions())

or

wdComponentAPI.getMessageManager().isEmpty()

Former Member
0 Kudos

Hi LM,

You are exactly right. I can display the message but it will not go away unless the user clicks on a button or some other action to force a refresh. But using the calucalted attribute does not cause a refresh so the message stays whether it has been corrected by the user or not. My hope is that there is a way to force an exception to be removed or to clear all exceptions.

Thanks,

-Kevin

lajitha_menon
Contributor
0 Kudos

Hi Kevin,

Even if you are using calculated attributes, it will get the values for these attributes only if an action has been initiated. It does not 'automatically' refresh the screen. The difference is that it will refresh the screen if you do things like selecting values from a value help, unlike just hitting enter or clicking a button. Now, how can we expect the system to understand that we have changed the input, without initiating any action that specifies so?

Maybe you can use a timedtrigger or something that constantly listens and forces a refresh, but I am not sure about that, also It would increase processing times.

Cheers,

LM

Former Member
0 Kudos

Hi LM,

Actually, with a calculated attribute, the methods will be called when you click on another input field and not just by clicking a button or clicking enter. Here in lies the problem.

What we have are a number of input fields with one final input field (read only) for Total. Everytime you click on an input field to enter a new Amount, this causes the calculated attribute for the Total field to set off GetTotal(), which then adds all the Amounts together to get the Total.

When GetTotal() is called it will validate the Amount fields and we throw an exception if it doesnt meet our criteria. The problem is, unlike a button click, this will not clear any Exception Messages. Even thought the Amount may pass validation, it remains marked as invalid and the error messages remain.

I appreciate your suggestions LM, but unfortunately, I think we are kind of getting away from my original question though. What i need is to know is if there is some way i can clear messages from the screen?

Any ideas out there?

Thanks,

-Kevin

Sharadha1
Active Contributor
0 Kudos

Hi Kevin,

When ever the attribute bcomes valid, justmark it as VALID using the api.

IWDValidationCheck valCheck = wdComponentAPI.getValidationCheck();

IWDAttributeInfo attrinfo = wdContext.getNodeInfo().getAttribute("attr1");

valCheck.setAttributeValid(currentelem,attrinfo);

This will remove the messages from the IWDMESSAGEMANAGER's buffer, and hence no messages will be displayed in the screen.

hope this helps..

Regards,

Sharadha

Former Member
0 Kudos

Hi Sharadha,

I did try that as well with no joy. But I have solved it on my own. The problem was using a Table where I have a column of Amounts and the need to calculate a total and apply it to a Total field. This is a simple task with many tutorials on how to do it. But the issue was when we applied our own validation to the Amounts during this calculation.

If the validation was false an AttributeMessage was applied to that particular cell, but as the calucaltion/validation was applied using a calculated attribute Get Method, there was never an event fired to clear out any attribute messages that were no longer needed. There is also an issue that if a user clicks on a differnt Amount field in the table, the same attribute message would appear over and over because the originals would not be cleared from the view because no event was fired to clear the view.

I removed the calculated attribute property from the Total field and instead applied an onleadselection action to the table. Now whether the user clicks on a new input field within the table or clicks Enter, clicks a button, etc. my calculation/validation method is called and all is well.

Thank you both for your help on this. Take care,

-Kevin