How to display error in same page
Hi There ,
I am new to jsf. My requirement is I have to display error message on the same page if login fails .
So I have some thing like this in faces-config.xml
<navigation-rule>
<from-view-id>/pages/inputname.jsp</from-view-id>
<navigation-case>
<from-outcome>failure</from-outcome>
<to-view-id>/pages/inputname.jsp</to-view-id>
</navigation-case>
....
So I am not sure how to code inside inputname.jsp so that if navigation case is failure to show the error message.
Any suggestions are kindly welcome.
-Thanks
Priyannka
# 1
If you check the login information in the action method, let this method creates new error message and then return null. In this case, the same page will be re-displayed and the error message is shown. No one record is required in the faces-config.xml in this case.
# 2
first create a message in jsp:
<h:messages layout="table" showDetail="true" showSummary="false" styleClass="errMsg" id="message" />
then in your backing bean: FacesMessage errmsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "summary", errorMessage); FacesContext.getCurrentInstance().addMessage(null, errmsg); //add this where you want to display the errorMessage... errorMessage is the actual error message that you want to display on the screen like "Invalid Input Data"
gsrya at 2007-7-12 3:30:03 >
