cancel
Showing results for 
Search instead for 
Did you mean: 

Message Pool

Former Member
0 Kudos

Hi

I am trying to create a common message pool for all devlopment components i.e

I want to have a devlopment component which contains all the messages in the message pool. I want to use this component in other devlopment components for the error messages. The main idea being .. we will have a centralised access to the messages

I tried doing the following..

if component (CompA) contains all the messages

in the interface controller of CompA i declared a method which returns the message manager.(getMsgManager)

CompB - I used the CompA in CompB. I am able to get the message manager of CompA. but i am not able to access the messages of the CompA.

i tried this.

wdThis.wdGetInterfaceController(CompA).getMsgManager().raiseException(..).

here i am not able to access the messages of CompA as we general do.. i.e IMessage<Component Name>.<Error ID>

Pl. help me out if any one tried this or if there is any better approach to maintain the error messages centrally.

Regards

NagaKishore V

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi NagaKishore,

as the message manager is application wide the only thing you need to get is the translated text so you can raise the exception in the component B. You can do this by defining a interface method in comp A like getTranslatedText(String MSGKEY).

Another way is to expose the raiseException(Exception e) in the interface controller of comp A. The advantage of this wrapper is, you can easily extend it later on like adding logging functionality on a central point in comp A. We're going this way in our project.

Best regards,

Christian

Former Member
0 Kudos

Hi Christian

Thanks for the Help. Can you please elobrate the second option so that i can try that.

Regards

NagaKishore V

Former Member
0 Kudos

Hi NagaKishore,

just add a method raiseException(Exception e) to the interface controller of component A.

Therein invoke the message manager of that component:


@@begin
wdComponentAPI.wdGetMessageManager.raiseException(e);
@@end

The same can be done for other message manager methods too.

Depending on your needs evaluate the parameter and use the message pool of comp A. This can be done for exceptions too. If it's a custom exception just define the exception as a key and use the message pool to map it.

This is an example for handling all Exceptions starting with "myerror". Corresponding message pool entry is prerequisite:


if (e.toString().startsWith("myerror")) {
wdComponentAPI.wdGetMessageManager.reportError(
wdComponentAPI.getTextAccessor().getText(
e.toString()
))
}

....

The trick is, that even if comp A doesn't have a view the message manager of that component is still able to display it's message thorugh the message api...

In component B just invoke that methods.

That's it!

Best regards,

Christian