cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieving all Error and Warning messages.

Former Member
0 Kudos

Hi all,

I need to show all the messages in popup window and\or write them to file (not log all of them but write only for present moment).

Is it possible to get list of all reported messages? Maybe like MessageArea do?

Edited by: ANTON HRYDZIN on Apr 30, 2008 5:52 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Anton,

Create a method in Component controller and call where ever you want to display the error or warning messages.


if( type.equals( "Error"))
{
   	wdComponentAPI.getMessageManager().reportException( message, true);
}else if( type.equals( "Warning"))
{
        wdComponentAPI.getMessageManager().reportWarning( message);
}else
{
	wdComponentAPI.getMessageManager().reportSuccess( message);
}
try
{
   BufferedWriter bufferedwriter = new BufferedWriter( new FileWriter( <filepath>)); 
   bufferedwriter.write( message);
   bufferedwriter.close();
} catch (IOException e)
{
		// TODO Auto-generated catch block
               openMessage( e.getLocalizedMessage(), "Error");
		e.printStackTrace();
}

In button press or any event triggering part put this code:


wdThis.wdGetTestComponentController().openMessage( "First button Pressed", "Success");

You can see the file in J2EE server in specified location.

Regards

Vinod V

Answers (3)

Answers (3)

ReenaWadhwa
Advisor
Advisor
0 Kudos

Hi all,

Can anyone help here? i also have same problem. I have to get list all the enteries of message pool regardless of entry type. is it possible?

thanks

Reena

Former Member
0 Kudos

Problem is not in showing the message, but in getting of all the messages. Can we somehow get all the messages from MessageManager or from any were else, just like MessageArea do? Without editing code, that sends all this messages.

nikhil_bose
Active Contributor
0 Kudos

if those messages are defined in message pool we can get it as those are end-user generated.

nikhil_bose
Active Contributor
0 Kudos

For displaying window


	IWDControllerInfo contInfo = wdControllerAPI.getViewInfo().getViewController();
   	
	IWDConfirmationDialog dialog = wdComponentAPI.getWindowManager().createConfirmationWindow( "Your Message", contInfo.findInEventHandlers( "okMethod"), "OK");

	dialog.show();

where okMethod is a predefined method where you can append those messages to write to file

e.g.


  public void okMethod(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin ok(ServerEvent)
String log =  wdContext.currentContextElement().getLogs();
log+= "new messages"
 wdContext.currentContextElement().setLogs(log);
    //@@end
  }

you can use File class to write all logs to a file.

http://java.sun.com/j2se/1.3/docs/api/java/io/File.html

nikhiL