久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

JSF 2:ajax 調用后的頁面重定向

JSF 2: page redirect after ajax call(JSF 2:ajax 調用后的頁面重定向)
本文介紹了JSF 2:ajax 調用后的頁面重定向的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我遇到了類似于 this 的導航案例問題.簡而言之,我正在嘗試使用 ajax 呈現(xiàn)的 h:commandLink 將導航從一個頁面重定向到另一個頁面.這是支持 bean

I'm stuck in a navigation case problem similar to this one. In a few words, I'm trying to redirect navigation from one page to another, using an ajax rendered h:commandLink. Here's the backing bean

@ManagedBean
public class StartBean {

    public void search(){
        FacesContext
            .getCurrentInstance()
            .getExternalContext()
            .getFlash()
            .put("result", "hooray!")
        ;
    }

    public String showResult(){
        return "result?faces-redirect=true";
    }
}

和起始頁

<h:body>
    <h:form prependId="false">
        <h:commandButton value="Click" action="#{startBean.search}">
            <f:ajax execute="@this" render="@form"/>
        </h:commandButton>
    
        <br/>
         
        <h:commandLink 
            action="#{startBean.showResult()}" 
            rendered="#{flash.result != null}" 
            value="#{flash.result}"
        />
    
    </h:form>
</h:body>

result 頁面只是顯示一條消息.兩個頁面都在 Web 模塊上下文根目錄中.碰巧 h:commandLink 在ajax提交后正確顯示,但單擊它會導致頁面刷新.它不會像預期的那樣重定向到 result 頁面.之后,如果頁面被重新加載(F5),result 頁面就會顯示出來.這似乎是一個渲染周期的問題.

whereas result page is just showing a message. Both pages are on web module context root. It happens that the h:commandLink is correctly displayed after ajax submit, but clicking on it causes a page refresh. It doesn't redirect towards the result page, as expected. After it, if page is reloaded (F5), result page is shown. It seems to be a rendering cycle matter.

有什么建議嗎?

提前致謝.

推薦答案

所有輸入和命令組件的 rendered 屬性在提交表單時重新評估.因此,如果它評估 false,則 JSF 根本不會調用該操作.search() 方法的請求/響應完成后,F(xiàn)lash 作用域終止.當您發(fā)送 showResult() 的請求時,它不再存在于 Flash 范圍內.我建議將 bean 放在視圖范圍內,并將 rendered 屬性綁定到它的屬性.

The rendered attribute of all input and command components is re-evaluated when the form is submitted. So if it evaluates false, then JSF simply won't invoke the action. The Flash scope is terminated when the request/response of the search() method is finished. It isn't there in the Flash scope anymore when you send the request of the showResult(). I suggest to put the bean in the view scope and bind the rendered attribute to its property instead.

@ManagedBean
@ViewScoped
public class StartBean {

    private String result;

    public void search(){
        result = "hooray";
    }

    public String showResult(){
        return "result?faces-redirect=true";
    }

    public String getResult() {
        return result;
    }

}

<h:commandLink 
    action="#{startBean.showResult}" 
    rendered="#{startBean.result != null}" 
    value="#{startBean.result}"
/>

另見:

  • commandButton/commandLink/ajax action/listener 方法未調用或輸入值未更新
  • 這篇關于JSF 2:ajax 調用后的頁面重定向的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

    【網站聲明】本站部分內容來源于互聯(lián)網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

Adding space between buttons?(在按鈕之間添加空間?)
Sencha Touch Ext.navigation.View pop to root(Sencha Touch Ext.navigation.View pop to root)
Simple 2-column navigation with CSS and a single list?(使用 CSS 和單個列表的簡單 2 列導航?)
Single page navigation menu - active indicator(單頁導航菜單 - 活動指示器)
vertical navigation with rotated text(帶有旋轉文本的垂直導航)
Evenly spaced list items(均勻分布的列表項)
主站蜘蛛池模板: 中文在线视频 | 天天爽天天干 | 精品二区视频 | 一区二区免费 | 99热.com| 中文字幕成人av | 91精品国产色综合久久 | 亚洲人成在线播放 | 精品久久久久久红码专区 | 日韩欧美在线观看视频 | 免费黄视频网站 | 亚洲一区二区三区四区五区午夜 | 国产在线一区观看 | av播播| 午夜在线观看视频 | 国产精品无码久久久久 | 超碰日本 | 久草网址| 精品久久久久久红码专区 | 黄色av免费网站 | 一级看片免费视频 | 亚洲精品免费在线 | 日本涩涩网 | 欧美成人综合 | 蜜桃视频麻豆 | 黄a网站 | 天天操,夜夜爽 | 日本高清视频在线播放 | 久草视频在线播放 | 日本aⅴ中文字幕 | 精品国产乱码久久久久久影片 | 日韩中文在线视频 | 国产午夜精品久久久 | 亚洲一区二区三区在线 | 天天操 天天操 | 日日爱夜夜操 | www.五月天婷婷.com | 奇米av| 亚洲视频自拍 | 伊人操| cao在线 |