cancel
Showing results for 
Search instead for 
Did you mean: 

Using System.out.println or System.err.println

former_member182374
Active Contributor
0 Kudos

Hi All,

I've a Web Dynpro project which uses a simple java helper class.

The java class has 'try catch' statements.

When I'm in 'catch' I want to display an error message on the screen.

I know that System.err.println writes the message in the defaultTrace.trc log file in the server but as a developer I don't always have access to the server.

Is there an option to display the error message on the screen with some kind of response object? (I cannot use wdComponentAPI.getMessageManager.reportSuccess in my helper class)

Thanks,

Omri

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Omri,

It's not true that you cannot use the MessageManager in your helper java classes. Here's how you can do it:

1. Create a java class in the src directory of your project and in the same packeage as your project. I think you have already done this. Let's say the class is called HelperClass.

2. Declare a public variable of type com.sap.tc.webdynpro.progmodel.api.IWDMessageManager. Call it say, msgManager. The import will be added automatically.

3. In the wdDoInit() of your WD write something like:


HelperClass helperObj = new HelperClass();
helperObj.msgManager  = wdComponentAPI.getMessageManager();

4. Then when you catch the exception in your helper class, do a simple reportException().

Regards,

Satyajit.

sridhar_k2
Active Contributor
0 Kudos

Hi Satyajit,

Thanks for Correcting me. It is working fine. This is the better way than, what i suggested.

Regards,

Sridhar

former_member182374
Active Contributor
0 Kudos

Thanks Satyajit Chakraborty

Problem solved

Answers (1)

Answers (1)

sridhar_k2
Active Contributor
0 Kudos

Hi Omri,

You are true..that you can not directly use MessageManager Class.

For that there is a work around, If that method returns a String, you can find out what exception in the Called view.

you can write in this way.

try{

return null // No Exception

}catch(Exception exp){

return exp.toString(); // If exception is there

}

Regards,

Sridhar