簡體   English   中英

h:commandButton提交后為空白頁

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM