on 06-08-2009 12:51 PM
Hi Experts,
In my application iam using two methods, iam calling Method A in Method B.
Method A is throwing one exception based on one condition i used wdComponentAPI.getMessageManager().reportInvalidContextAttributeException(
when this exception raised in Method A its showing exception message and its not able to stop to call Method B.
so i called the same exception based on the same condition what i checked in method A,
so in method b also showing exception messages but i want to show only one exception message what to do
plz help me in this
regards,
sush
Hi,
Create one context attribute example "Error Displayed" of boolean type and control your code as below.
public void methodA( )
{
if(validate==false)
{
wdContext.currentContextElement().setErrorDisplayed(true);
wdComponentAPI.getMessageManager().reportException("Error",true);
}
}
public void methodB( )
{
methodA();
if(wdContext.currentContextElement().getErrorDisplayed()==false && validate==false)
{
wdComponentAPI.getMessageManager().reportException("Error",true);
}
}
Regards,
Charan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
you may also use some "real" exceptions in your coding. In your outer method place a try-catch block and throw some meaningful exceptions in your inner and outer method.
In the catch do the reporting of the exceptions.
But keep in mind, exceptions are "costly". If you have just an input check on your context, then it maybe better to create a dedicated method for checking your context and other input before you go to any further method.
Hope that helps a little bit,
Frank
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.