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:[EMAIL PROTECTED]
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