cancel
Showing results for 
Search instead for 
Did you mean: 

How to read the Key value from the Message using the text value.. Urgent

Former Member
0 Kudos

I need to read the Key valuefrom the message pool using the text value for the Key.. Is it possible.. Please help me with sample code..

Thanks and Regards

Avijit

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Satyajit ,

the code that you have written does not meet my requirement because I only have the text value.. not the key.. I will have to find the key using the text value.

Thanks

Avijit

Former Member
0 Kudos

Hi ,

Thanks for your reply.. but my requirement is opposite to the one you specified. I have to read the Key value from the Message Pool using the text.

Please help.

thanks and Regards

Avijit

Former Member
0 Kudos

Hi,

I couldn't test this code, but you can try.

WDMessage msg = (WDMessage)IMessage<ComponentName>.<Key>;
		
String key = msg.getMessageKey();

I understand that this is not exactly what you are looking for, but I don't think there's another way.

Regards,

Satyajit.

former_member182294
Active Contributor
0 Kudos

Avijit,

I got your requirement. I really dont know the scenario your working on but its possible to do it. There is no direct way to do so, but complexity is in getting to know the Keys dynamically from interface.

Here you go..

	try
	{
		Class msgClass 	= IMessageTestWDApps.class;
//Replace IMessageTestWDApps with IMessage<Your WD Component name>
		Field keys[] 	= msgClass.getFields();
		IWDTextAccessor textAccessor = wdComponentAPI.getTextAccessor();
		
		if(keys != null)
		{
			String key = "";
			for(int index=0;index<keys.length;index++)
			{
				key = keys[index].getName();
				wdComponentAPI.getMessageManager().reportSuccess("Key= "+key);
				
				if(textAccessor.getText(key).equals("My message text"))
				{
					//your logic.
				}
			}
		}
	}
	catch(Exception cnfe)
	{
		wdComponentAPI.getMessageManager().reportException("Exe "+cnfe.getMessage(),false);
	}

Regards

Abhilash

Message was edited by:

Abhilash Gampa

former_member182294
Active Contributor
0 Kudos

Hi Avijit,

Here is the sample code to get the text from Msg pool.

IWDTextAccessor textAccessor = wdComponentAPI.getTextAccessor();

textAccessor.getText("KEY1");

//OR

textAccessor.getText(IMessage<CompName>.KEY2);

Regards

Abhilash