You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Alexandre Jaquet <a....@avintis.com> on 2006/09/08 10:34:32 UTC
FacesMessage displayed two times
Hi,
When I've some error, the error message is displayed two times with my
code :
example :
if (validateAction() == false)
UtilGui.setJSFErrorMessage("action_null", new Exception());
public static void setJSFErrorMessage(String errorIdFromBundle,
Exception fromEx) {
if (errorIdFromBundle == null ||
errorIdFromBundle.trim().length() == 0) {
ec.handleError("Invalid ERROR ID", ErrorLevel.FATAL);
}
FacesContext context = FacesContext.getCurrentInstance();
ResourceBundle myRessourceBundle =
ResourceBundle.getBundle("Errors", context.getViewRoot().getLocale());
String myTranslatedString;
try {
myTranslatedString =
myRessourceBundle.getString(errorIdFromBundle);
} catch (MissingResourceException ex) {
myTranslatedString = "[missing key '" + errorIdFromBundle +
"' in properties file]";
}
context.addMessage(null, new FacesMessage(myTranslatedString));
if (UtilGui.DEBUG_MODE && fromEx != null) {
context.addMessage(null, new FacesMessage(fromEx.getMessage()));
fromEx.printStackTrace();
}
}
any idea how to fix it ?
my best regards
Re: FacesMessage displayed two times
Posted by Mike Kienenberger <mk...@gmail.com>.
What's your page code look like?
On 9/8/06, Alexandre Jaquet <a....@avintis.com> wrote:
> Hi,
>
> When I've some error, the error message is displayed two times with my
> code :
>
> example :
>
> if (validateAction() == false)
> UtilGui.setJSFErrorMessage("action_null", new Exception());
>
> public static void setJSFErrorMessage(String errorIdFromBundle,
> Exception fromEx) {
> if (errorIdFromBundle == null ||
> errorIdFromBundle.trim().length() == 0) {
> ec.handleError("Invalid ERROR ID", ErrorLevel.FATAL);
> }
> FacesContext context = FacesContext.getCurrentInstance();
> ResourceBundle myRessourceBundle =
> ResourceBundle.getBundle("Errors", context.getViewRoot().getLocale());
> String myTranslatedString;
> try {
> myTranslatedString =
> myRessourceBundle.getString(errorIdFromBundle);
> } catch (MissingResourceException ex) {
> myTranslatedString = "[missing key '" + errorIdFromBundle +
> "' in properties file]";
> }
> context.addMessage(null, new FacesMessage(myTranslatedString));
> if (UtilGui.DEBUG_MODE && fromEx != null) {
> context.addMessage(null, new FacesMessage(fromEx.getMessage()));
> fromEx.printStackTrace();
> }
> }
> any idea how to fix it ?
>
> my best regards
>