[英]Empty page after h:commandButton submit
我有一個JSF 2.2頁面,其中包含表單和<h:commandButton>
來調用該方法,在提交按鈕之后,該方法成功調用,並且所有指令都可以正常工作
問題 :提交按鈕后,我得到一個空白頁,瀏覽器中的URL仍然不變
我想要的是提交后,頁面保持不變並顯示咆哮消息。
managedBean.java
@ManagedBean(name="consignmentShipBean")
@ViewScoped
public class ConsignmentShipBean implements Serializable{
public void send(){
//some instructions to do
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage("Successful", "__") );
}
}
page.xhtml
<p:growl id="growl" globalOnly="true" autoUpdate="true"/>
<h:form>
...
<h:commandButton value="Send" actionListener="#{consignmentShipBean.send}" />
</h:form>
提交按鈕后更新結果:
您必須執行Ajax請求,而不是通常的請求。 使用標准按鈕或PrimeFaces按鈕:
<h:commandButton value="Send" actionListener="#{consignmentShipBean.send}" >
<f:ajax update="growl"/>
</h:commandButton>
要么
<p:commandButton value="Send"
actionListener="#{consignmentShipBean.send}" update="growl" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.