h:commandLink在调用操作之前刷新页面

时间:2013-08-21 19:51:23

标签: jsf-2

我有一个带有注销按钮的页面,它是h:commandLink

<h:form>
                <div id="top-nav">
                    <div id="logout" style="float: right; margin-left: 10px;">

                        <h:commandLink styleClass="top-nav-btn"
                            action="#{adminLogoutBean.logout}"
                            rendered="#{facesContext.externalContext.sessionMap['ccUserVO'] ne null}" value="Logout" immediate="true">
                            <f:ajax execute="@form" render="@none" /> 
                            </h:commandLink>


                    </div>


                        <div style="margin-left: -80px;  margin-top: 70px;">
                            <p style="float: left;margin-left: 10px;">Please
                                enter client VIN or EMAIL</p>
                            <br />
                            <h:inputText styleClass="menus txfld_border_no_image required email"
                                minlength="5" style="width:300px;clear:right;display:inline;"
                                id="loginEmail" value="#{callCenterAdminBean.searchText}" />
                            <span class="btn-wrap" id="get_enabled"> <h:commandButton type="submit"
                                    class="common_btn noprint submit" id="userlookup_btn" value="GET"
                                    action="#{callCenterAdminBean.userLookup}">

                                </h:commandButton> </span>
                            <span class="btn-wrap" id="get_disabled" style="display:none"> <h:commandButton type="submit"
                                    class="common_btn noprint submit" disabled='true' value="GET"
                                    action="#{callCenterAdminBean.userLookup}">

                            </h:commandButton> </span>
                        </div>
                    </h:panelGroup>
                </div>

            </h:form>

当我点击Logout时,我发现页面先刷新,然后调用该动作。为什么页面刷新?我想调用bean方法,它将使用导航规则重定向到登录页面。

1 个答案:

答案 0 :(得分:0)

如果您想使用导航,则不需要ajax,只需删除

即可
<f:ajax execute="@form" render="@none" />

并删除immediate="true"因为我认为您在以下用例中没有任何理由使用它...