如何顯示成功消息?我有以下代碼,但只有警告消息出現。我必須改變什麼,以便成功消息將顯示在我的成功頁面中?如何在jsf 2上顯示成功消息
userbean.java:
public String Login() throws Exception {
String status = "failure";
current=userBo.validateUser(getLogin(),getPass());
if(current!=null){ exist=false; status = "success";
String message = "submitted successfully !!";
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(message)); }
exist=true; return status; }
login.xhtml:
<f:view>
<h:form>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<th>Username</th>
<td><h:inputText value="#{user.login}"
styleClass="login-inp" /></td>
</tr>
<tr>
<th>Password</th>
<td><h:inputSecret value="#{user.pass}"
onfocus="this.value=''" styleClass="login-inp" /></td>
</tr>
<tr>
<th></th>
<!-- <td><input type="button" class="submit-login" /> -->
<td><h:commandButton action="#{user.checkUser}" styleClass="submit-login" />
<h:messages globalOnly="true" />
</td>
</tr>
</table>
</h:form>
</f:view>
success.xhtml:
<h:form>
<h:body>
<h1>heyyyy ,y sucseded !!!</h1> <br/><br/>
<h:commandLink action ="#{user.logout}" > disconnect </h:commandLink>
</h:body>
</h:form>
警告消息:
Infos: WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=null[severity=(INFO 0), summary=(submitted successfully !!), detail=(submitted successfully !!)]
現在它完美的工作,謝謝Mr.BalusC! – Ziko