You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Aleksei Valikov <va...@gmx.net> on 2006/05/26 11:23:37 UTC

Handling and displaying action errors

Hi.

In JSF, validating "fields" works like a sharm. A validator checks the value and 
queues a message if anything's wrong. The message is the displayed by the 
h:message/h:messages tags/handlers within the page.

My question is - what is the analogue for this for actions? Imagine I have an 
action like "delete document" and when invoked it fails for some reason. How 
could I diagnose and handle the problem? For instance, if I get a 
DocumentNotExistsException, I know it's no the end of the days, I just have to 
queue a "documentNotExsists" message which would then be displayed in the page. 
But how does this work programmatically?

Thank you for your time.

Bye.
/lexi

Re: Handling and displaying action errors

Posted by Enrique Medina <e....@gmail.com>.
Hi Aleksei,

You can do it easily and in a centralized manner using an extension of the
default action listener. Here, all exceptions thrown by actions are
captured, so you can plug your own exception handling logic ;-)

Regards.

On 5/26/06, Aleksei Valikov <va...@gmx.net> wrote:
>
> Hi.
>
> In JSF, validating "fields" works like a sharm. A validator checks the
> value and
> queues a message if anything's wrong. The message is the displayed by the
> h:message/h:messages tags/handlers within the page.
>
> My question is - what is the analogue for this for actions? Imagine I have
> an
> action like "delete document" and when invoked it fails for some reason.
> How
> could I diagnose and handle the problem? For instance, if I get a
> DocumentNotExistsException, I know it's no the end of the days, I just
> have to
> queue a "documentNotExsists" message which would then be displayed in the
> page.
> But how does this work programmatically?
>
> Thank you for your time.
>
> Bye.
> /lexi
>

Re: Handling and displaying action errors

Posted by Gregg Bolinger <gd...@gmail.com>.
JSF in Action actually uses similar methods.  They build a BaseBean class
that all managed beans extend and this BaseBean class has some methods for
setting error and informational messages.

Gregg

On 6/19/06, Julian Ray <ju...@yahoo.com> wrote:
>
> No problem. Feel free to enhance, fix any errors/inconsistencies etc.
>
>
> -----Original Message-----
> From: Jeff Bischoff [mailto:jbischoff@klkurz.com]
> Sent: Monday, June 19, 2006 11:59 AM
> To: MyFaces Discussion
> Subject: Re: Handling and displaying action errors
>
> Looks like you've added both. Thanks a bunch Julian!
>
> Julian Ray wrote:
> > I have started this section, please contribute where you can -- if you
> > look on the WIKI I added a new section on handling messages/errors.
> >
> > There was also some earlier discussion about handling server 500
> > errors which should be added as well. If I can dig it out of the posts I
> will add.
> > --
> > View this message in context:
> > http://www.nabble.com/Handling-and-displaying-action-errors-t1685789.h
> > tml#a4926630 Sent from the MyFaces - Users forum at Nabble.com.
> >
> >
> >
> >
>
>
>

RE: Handling and displaying action errors

Posted by Julian Ray <ju...@yahoo.com>.
No problem. Feel free to enhance, fix any errors/inconsistencies etc.
 

-----Original Message-----
From: Jeff Bischoff [mailto:jbischoff@klkurz.com] 
Sent: Monday, June 19, 2006 11:59 AM
To: MyFaces Discussion
Subject: Re: Handling and displaying action errors

Looks like you've added both. Thanks a bunch Julian!

Julian Ray wrote:
> I have started this section, please contribute where you can -- if you 
> look on the WIKI I added a new section on handling messages/errors.
> 
> There was also some earlier discussion about handling server 500 
> errors which should be added as well. If I can dig it out of the posts I
will add.
> --
> View this message in context: 
> http://www.nabble.com/Handling-and-displaying-action-errors-t1685789.h
> tml#a4926630 Sent from the MyFaces - Users forum at Nabble.com.
> 
> 
> 
> 



Re: Handling and displaying action errors

Posted by Jeff Bischoff <jb...@klkurz.com>.
Looks like you've added both. Thanks a bunch Julian!

Julian Ray wrote:
> I have started this section, please contribute where you can -- if you look
> on the WIKI I added a new section on handling messages/errors. 
> 
> There was also some earlier discussion about handling server 500 errors
> which should be added as well. If I can dig it out of the posts I will add.
> --
> View this message in context: http://www.nabble.com/Handling-and-displaying-action-errors-t1685789.html#a4926630
> Sent from the MyFaces - Users forum at Nabble.com.
> 
> 
> 
> 



Re: Handling and displaying action errors

Posted by Julian Ray <ju...@yahoo.com>.
I have started this section, please contribute where you can -- if you look
on the WIKI I added a new section on handling messages/errors. 

There was also some earlier discussion about handling server 500 errors
which should be added as well. If I can dig it out of the posts I will add.
--
View this message in context: http://www.nabble.com/Handling-and-displaying-action-errors-t1685789.html#a4926630
Sent from the MyFaces - Users forum at Nabble.com.


Re: Handling and displaying action errors

Posted by Matthias Wessendorf <ma...@apache.org>.
Jeff,

go ahead! would be great

the pattern Julian described (with the setErrorMessage() for instance)
is also used in shale's AbstractViewController/AbstractFacesBean ([1]).
The nice thing is that a Shale ViewController also addeds some
*lifecycle hook* methods, like init() or prerender.

-Matthias

[1] http://struts.apache.org/struts-shale/shale-core/apidocs/org/apache/shale/view/AbstractViewController.html

On 6/16/06, Jeff Bischoff <jb...@klkurz.com> wrote:
> Julian,
>
> I like the methods you guys have for setting error messages. Seems that
> some JSF books lack such relatively basic information (e.g. Core
> JavaServer Faces)!
>
> Since we have nothing in the Wiki about error reporting, perhaps it
> would be useful to make such an entry. I could make a page describing a
> stripped-down version of your methodology, unless you have the time to
> make one yourself?
>
> Regards,
>
> Jeff Bischoff
> Kenneth L Kurz & Assoc, Inc.
>
> Julian Ray wrote:
> > Here you go.
> >
> > We include this file in every page
> >
> > <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
> > <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
> > <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
> > <%@ taglib uri="http://c2glogistics.com/cms" prefix="cms"%>
> >
> > <h:panelGrid styleClass="group" columns="2" cellpadding="2" cellspacing="0"
> > width="100%" columnClasses="buttonCol, leftAlignCol"
> > rowClasses="vertAlignTop" rendered="#{! empty facesContext.maximumSeverity}"
> >
> >       <h:graphicImage value="#{PageMessages.messageImage}" style="float:
> > left; vertical-align: top;" />
> >       <h:panelGrid columns="1" cellpadding="2" cellspacing="2"
> > columnClasses="leftAlignCol" rowClasses="vertAlignTop" width="100%">
> >           <h:outputText value="#{PageMessages.messageHeader}"
> > escape="false" rendered="#{PageMessages.renderMessage}"/>
> >           <h:messages errorClass="errorMessage" infoClass="infoMessage"
> > layout="table" globalOnly="true" showDetail="false" showSummary="true"/>
> >       </h:panelGrid>
> > </h:panelGrid>
> >
> > It is backed up by a request-scoped backing bean which knows how to place
> > message-specific images into the page
> >
> > import javax.faces.application.FacesMessage;
> > import javax.faces.application.FacesMessage.Severity;
> >
> > import org.apache.commons.lang.StringUtils;
> >
> > import cms.beans.Messages;
> >
> > public class PageMessages extends AbstractUIBean {
> >       private static final long serialVersionUID = -6479897299239746841L;
> >       private static final String BEAN_NAME =
> > PageMessages.class.getName();
> >     private String messageHeader;
> >     private String messageImage;
> >     private Severity severityLevel;
> >
> >     public PageMessages() {
> >
> >       messageHeader = null;
> >
> >         // See if there are messages queued for the page
> >         severityLevel = getFacesContext().getMaximumSeverity();
> >         if (null != severityLevel) {
> >             getLogger().debug("Severity Level Trapped: level = '" +
> > severityLevel.toString() + "'");
> >             if (severityLevel.compareTo(FacesMessage.SEVERITY_ERROR) == 0) {
> >                 messageHeader = Messages.getString("PAGE_MESSAGE_ERROR");
> >                 messageImage = "resources/warning.gif";
> >             } else if (severityLevel.compareTo(FacesMessage.SEVERITY_INFO)
> > == 0) {
> >                 messageHeader = null;
> >                 messageImage = "resources/information.gif";
> >             } else if (severityLevel.compareTo(FacesMessage.SEVERITY_WARN)
> > == 0) {
> >                 messageHeader = null;
> >                 messageImage = "resources/warning.gif";
> >             } else if (severityLevel.compareTo(FacesMessage.SEVERITY_FATAL)
> > == 0) {
> >                 messageHeader = Messages.getString("PAGE_FATAL_ERROR");
> >                 messageImage = "resources/stop.gif";
> >             }
> >         } else {
> >             getLogger().debug("Severity Level Trapped: level = 'null'");
> >         }
> >     }
> >     public Boolean getRenderMessage() {
> >       return new Boolean(StringUtils.isNotBlank(getMessageHeader()));
> >     }
> >     /*
> >      * Local Methods
> >      */
> >     /*
> >      * Overrides
> >      */
> >     public String getBeanName() {
> >         return BEAN_NAME;
> >     }
> >
> >     /*
> >      * Actions
> >      */
> >     /*
> >      * Listeners
> >      */
> >     /*
> >      * Validators
> >      */
> >     /*
> >      * Accessors
> >      */
> >     public String getMessageHeader() {
> >         return messageHeader;
> >     }
> >     public String getMessageImage() {
> >         return messageImage;
> >     }
> > }
> >
> >
> > -----Original Message-----
> > From: Aleksei Valikov [mailto:valikov@gmx.net]
> > Sent: Friday, May 26, 2006 6:19 AM
> > To: MyFaces Discussion
> > Subject: Re: Handling and displaying action errors
> >
> > Hi.
> >
> >
> >>The action method bindings of the backing beans process the request
> >>and can determine the next view through returning a navigation
> >>control. Null re-displays the current view so you can set up logic
> >>which goes
> >>
> >>If (someBusinessLogic()) {
> >>      displayConfirmationMessage();
> >>      return myNextView;
> >>} else {
> >>      displayErrorMessage();
> >>      return null;
> >>}
> >>
> >>We have a message area included on each JSP page which processes
> >>actions and inform the user of processing outcomes by using the
> >>Message interface and sending warnings, errors and info messages. Each
> >>of our backing beans inherits the following
> >>
> >>    protected void setInfoMessage(String msg) {
> >>        getFacesContext().addMessage(null, new
> >>FacesMessage(FacesMessage.SEVERITY_INFO, msg, null));
> >>    }
> >>
> >>    protected void setWarnMessage(String msg) {
> >>        getFacesContext().addMessage(null, new
> >>FacesMessage(FacesMessage.SEVERITY_WARN, msg, null));
> >>    }
> >>    protected void setErrorMessage(String msg) {
> >>        getFacesContext().addMessage(null, new
> >>FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null));
> >>    }
> >
> >
> > Well, this looks fine. So you just queue a message for the null client id?
> > How do you display messages for null within the mage? Could you please post
> > the corresponding code for the message area?
> >
> > Thank you.
> >
> > Bye.
> > /lexi
> >
> >
> >
>
>
>


-- 
Matthias Wessendorf
Aechterhoek 18
48282 Emsdetten
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

Re: Handling and displaying action errors

Posted by Jeff Bischoff <jb...@klkurz.com>.
Julian,

I like the methods you guys have for setting error messages. Seems that 
some JSF books lack such relatively basic information (e.g. Core 
JavaServer Faces)!

Since we have nothing in the Wiki about error reporting, perhaps it 
would be useful to make such an entry. I could make a page describing a 
stripped-down version of your methodology, unless you have the time to 
make one yourself?

Regards,

Jeff Bischoff
Kenneth L Kurz & Assoc, Inc.

Julian Ray wrote:
> Here you go.
> 
> We include this file in every page 
> 
> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
> <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
> <%@ taglib uri="http://c2glogistics.com/cms" prefix="cms"%>
> 
> <h:panelGrid styleClass="group" columns="2" cellpadding="2" cellspacing="0"
> width="100%" columnClasses="buttonCol, leftAlignCol"
> rowClasses="vertAlignTop" rendered="#{! empty facesContext.maximumSeverity}"
> 
> 	<h:graphicImage value="#{PageMessages.messageImage}" style="float:
> left; vertical-align: top;" />	
> 	<h:panelGrid columns="1" cellpadding="2" cellspacing="2"
> columnClasses="leftAlignCol" rowClasses="vertAlignTop" width="100%">	
> 	    <h:outputText value="#{PageMessages.messageHeader}"
> escape="false" rendered="#{PageMessages.renderMessage}"/>
> 	    <h:messages errorClass="errorMessage" infoClass="infoMessage"
> layout="table" globalOnly="true" showDetail="false" showSummary="true"/>
> 	</h:panelGrid>
> </h:panelGrid>
> 
> It is backed up by a request-scoped backing bean which knows how to place
> message-specific images into the page
> 
> import javax.faces.application.FacesMessage;
> import javax.faces.application.FacesMessage.Severity;
> 
> import org.apache.commons.lang.StringUtils;
> 
> import cms.beans.Messages;
> 
> public class PageMessages extends AbstractUIBean {
> 	private static final long serialVersionUID = -6479897299239746841L;
> 	private static final String BEAN_NAME =
> PageMessages.class.getName();
>     private String messageHeader;
>     private String messageImage;
>     private Severity severityLevel;
> 
>     public PageMessages() {
> 
>     	messageHeader = null;
>     	
>         // See if there are messages queued for the page
>         severityLevel = getFacesContext().getMaximumSeverity();
>         if (null != severityLevel) {
>             getLogger().debug("Severity Level Trapped: level = '" +
> severityLevel.toString() + "'");
>             if (severityLevel.compareTo(FacesMessage.SEVERITY_ERROR) == 0) {
>                 messageHeader = Messages.getString("PAGE_MESSAGE_ERROR");
>                 messageImage = "resources/warning.gif";
>             } else if (severityLevel.compareTo(FacesMessage.SEVERITY_INFO)
> == 0) {
>                 messageHeader = null;
>                 messageImage = "resources/information.gif";
>             } else if (severityLevel.compareTo(FacesMessage.SEVERITY_WARN)
> == 0) {
>                 messageHeader = null;
>                 messageImage = "resources/warning.gif";
>             } else if (severityLevel.compareTo(FacesMessage.SEVERITY_FATAL)
> == 0) {
>                 messageHeader = Messages.getString("PAGE_FATAL_ERROR");
>                 messageImage = "resources/stop.gif";
>             }
>         } else {
>             getLogger().debug("Severity Level Trapped: level = 'null'");
>         }
>     }
>     public Boolean getRenderMessage() {
>     	return new Boolean(StringUtils.isNotBlank(getMessageHeader()));
>     }
>     /*
>      * Local Methods
>      */
>     /*
>      * Overrides
>      */
>     public String getBeanName() {
>         return BEAN_NAME;
>     }
> 
>     /*
>      * Actions
>      */
>     /*
>      * Listeners
>      */
>     /*
>      * Validators
>      */
>     /*
>      * Accessors
>      */
>     public String getMessageHeader() {
>         return messageHeader;
>     }
>     public String getMessageImage() {
>         return messageImage;
>     }
> }
> 	
> 
> -----Original Message-----
> From: Aleksei Valikov [mailto:valikov@gmx.net] 
> Sent: Friday, May 26, 2006 6:19 AM
> To: MyFaces Discussion
> Subject: Re: Handling and displaying action errors
> 
> Hi.
> 
> 
>>The action method bindings of the backing beans process the request 
>>and can determine the next view through returning a navigation 
>>control. Null re-displays the current view so you can set up logic 
>>which goes
>>
>>If (someBusinessLogic()) {
>>	displayConfirmationMessage();
>>	return myNextView;
>>} else {
>>	displayErrorMessage();
>>	return null;
>>}
>>
>>We have a message area included on each JSP page which processes 
>>actions and inform the user of processing outcomes by using the 
>>Message interface and sending warnings, errors and info messages. Each 
>>of our backing beans inherits the following
>>
>>    protected void setInfoMessage(String msg) {
>>        getFacesContext().addMessage(null, new 
>>FacesMessage(FacesMessage.SEVERITY_INFO, msg, null));
>>    }
>>
>>    protected void setWarnMessage(String msg) {
>>        getFacesContext().addMessage(null, new 
>>FacesMessage(FacesMessage.SEVERITY_WARN, msg, null));
>>    }
>>    protected void setErrorMessage(String msg) {
>>        getFacesContext().addMessage(null, new 
>>FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null));
>>    }
> 
> 
> Well, this looks fine. So you just queue a message for the null client id?
> How do you display messages for null within the mage? Could you please post
> the corresponding code for the message area?
> 
> Thank you.
> 
> Bye.
> /lexi
> 
> 
> 



Re: Handling and displaying action errors

Posted by Aleksei Valikov <va...@gmx.net>.
Hi.

> Here you go.

[skip]

Thanks a lot. I'll follow a similar strategy. What I missed was globalOnly 
attribute, now it's clear what to do.

Bye.
/lexi

RE: Handling and displaying action errors

Posted by Julian Ray <ju...@yahoo.com>.
Here you go.

We include this file in every page 

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%@ taglib uri="http://c2glogistics.com/cms" prefix="cms"%>

<h:panelGrid styleClass="group" columns="2" cellpadding="2" cellspacing="0"
width="100%" columnClasses="buttonCol, leftAlignCol"
rowClasses="vertAlignTop" rendered="#{! empty facesContext.maximumSeverity}"
>
	<h:graphicImage value="#{PageMessages.messageImage}" style="float:
left; vertical-align: top;" />	
	<h:panelGrid columns="1" cellpadding="2" cellspacing="2"
columnClasses="leftAlignCol" rowClasses="vertAlignTop" width="100%">	
	    <h:outputText value="#{PageMessages.messageHeader}"
escape="false" rendered="#{PageMessages.renderMessage}"/>
	    <h:messages errorClass="errorMessage" infoClass="infoMessage"
layout="table" globalOnly="true" showDetail="false" showSummary="true"/>
	</h:panelGrid>
</h:panelGrid>

It is backed up by a request-scoped backing bean which knows how to place
message-specific images into the page

import javax.faces.application.FacesMessage;
import javax.faces.application.FacesMessage.Severity;

import org.apache.commons.lang.StringUtils;

import cms.beans.Messages;

public class PageMessages extends AbstractUIBean {
	private static final long serialVersionUID = -6479897299239746841L;
	private static final String BEAN_NAME =
PageMessages.class.getName();
    private String messageHeader;
    private String messageImage;
    private Severity severityLevel;

    public PageMessages() {

    	messageHeader = null;
    	
        // See if there are messages queued for the page
        severityLevel = getFacesContext().getMaximumSeverity();
        if (null != severityLevel) {
            getLogger().debug("Severity Level Trapped: level = '" +
severityLevel.toString() + "'");
            if (severityLevel.compareTo(FacesMessage.SEVERITY_ERROR) == 0) {
                messageHeader = Messages.getString("PAGE_MESSAGE_ERROR");
                messageImage = "resources/warning.gif";
            } else if (severityLevel.compareTo(FacesMessage.SEVERITY_INFO)
== 0) {
                messageHeader = null;
                messageImage = "resources/information.gif";
            } else if (severityLevel.compareTo(FacesMessage.SEVERITY_WARN)
== 0) {
                messageHeader = null;
                messageImage = "resources/warning.gif";
            } else if (severityLevel.compareTo(FacesMessage.SEVERITY_FATAL)
== 0) {
                messageHeader = Messages.getString("PAGE_FATAL_ERROR");
                messageImage = "resources/stop.gif";
            }
        } else {
            getLogger().debug("Severity Level Trapped: level = 'null'");
        }
    }
    public Boolean getRenderMessage() {
    	return new Boolean(StringUtils.isNotBlank(getMessageHeader()));
    }
    /*
     * Local Methods
     */
    /*
     * Overrides
     */
    public String getBeanName() {
        return BEAN_NAME;
    }

    /*
     * Actions
     */
    /*
     * Listeners
     */
    /*
     * Validators
     */
    /*
     * Accessors
     */
    public String getMessageHeader() {
        return messageHeader;
    }
    public String getMessageImage() {
        return messageImage;
    }
}
	

-----Original Message-----
From: Aleksei Valikov [mailto:valikov@gmx.net] 
Sent: Friday, May 26, 2006 6:19 AM
To: MyFaces Discussion
Subject: Re: Handling and displaying action errors

Hi.

> The action method bindings of the backing beans process the request 
> and can determine the next view through returning a navigation 
> control. Null re-displays the current view so you can set up logic 
> which goes
> 
> If (someBusinessLogic()) {
> 	displayConfirmationMessage();
> 	return myNextView;
> } else {
> 	displayErrorMessage();
> 	return null;
> }
> 
> We have a message area included on each JSP page which processes 
> actions and inform the user of processing outcomes by using the 
> Message interface and sending warnings, errors and info messages. Each 
> of our backing beans inherits the following
> 
>     protected void setInfoMessage(String msg) {
>         getFacesContext().addMessage(null, new 
> FacesMessage(FacesMessage.SEVERITY_INFO, msg, null));
>     }
> 
>     protected void setWarnMessage(String msg) {
>         getFacesContext().addMessage(null, new 
> FacesMessage(FacesMessage.SEVERITY_WARN, msg, null));
>     }
>     protected void setErrorMessage(String msg) {
>         getFacesContext().addMessage(null, new 
> FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null));
>     }

Well, this looks fine. So you just queue a message for the null client id?
How do you display messages for null within the mage? Could you please post
the corresponding code for the message area?

Thank you.

Bye.
/lexi


Re: Handling and displaying action errors

Posted by Aleksei Valikov <va...@gmx.net>.
Hi.

> The action method bindings of the backing beans process the request and can
> determine the next view through returning a navigation control. Null
> re-displays the current view so you can set up logic which goes
> 
> If (someBusinessLogic()) {
> 	displayConfirmationMessage();
> 	return myNextView;
> } else {
> 	displayErrorMessage();
> 	return null;
> }
> 
> We have a message area included on each JSP page which processes actions and
> inform the user of processing outcomes by using the Message interface and
> sending warnings, errors and info messages. Each of our backing beans
> inherits the following 
> 
>     protected void setInfoMessage(String msg) {
>         getFacesContext().addMessage(null, new
> FacesMessage(FacesMessage.SEVERITY_INFO, msg, null));
>     }
> 
>     protected void setWarnMessage(String msg) {
>         getFacesContext().addMessage(null, new
> FacesMessage(FacesMessage.SEVERITY_WARN, msg, null));
>     }
>     protected void setErrorMessage(String msg) {
>         getFacesContext().addMessage(null, new
> FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null));
>     }

Well, this looks fine. So you just queue a message for the null client id?
How do you display messages for null within the mage? Could you please post the 
corresponding code for the message area?

Thank you.

Bye.
/lexi

RE: Handling and displaying action errors

Posted by Julian Ray <ju...@yahoo.com>.
Hi Alexi,

The action method bindings of the backing beans process the request and can
determine the next view through returning a navigation control. Null
re-displays the current view so you can set up logic which goes

If (someBusinessLogic()) {
	displayConfirmationMessage();
	return myNextView;
} else {
	displayErrorMessage();
	return null;
} 

We have a message area included on each JSP page which processes actions and
inform the user of processing outcomes by using the Message interface and
sending warnings, errors and info messages. Each of our backing beans
inherits the following 

    protected void setInfoMessage(String msg) {
        getFacesContext().addMessage(null, new
FacesMessage(FacesMessage.SEVERITY_INFO, msg, null));
    }

    protected void setWarnMessage(String msg) {
        getFacesContext().addMessage(null, new
FacesMessage(FacesMessage.SEVERITY_WARN, msg, null));
    }
    protected void setErrorMessage(String msg) {
        getFacesContext().addMessage(null, new
FacesMessage(FacesMessage.SEVERITY_ERROR, msg, null));
    }



-----Original Message-----
From: Aleksei Valikov [mailto:valikov@gmx.net] 
Sent: Friday, May 26, 2006 5:24 AM
To: MyFaces Discussion
Subject: Handling and displaying action errors

Hi.

In JSF, validating "fields" works like a sharm. A validator checks the value
and queues a message if anything's wrong. The message is the displayed by
the h:message/h:messages tags/handlers within the page.

My question is - what is the analogue for this for actions? Imagine I have
an action like "delete document" and when invoked it fails for some reason.
How could I diagnose and handle the problem? For instance, if I get a
DocumentNotExistsException, I know it's no the end of the days, I just have
to queue a "documentNotExsists" message which would then be displayed in the
page. 
But how does this work programmatically?

Thank you for your time.

Bye.
/lexi