如何在selectOneMenu选择的JSF中刷新页面? [英] How to refresh page in JSF on selectOneMenu selection?

查看:115
本文介绍了如何在selectOneMenu选择的JSF中刷新页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,其中包含PrimeFaces(2.2.1)编辑器组件,一个刷新"按钮和一个selectOneMenu,其选择会影响编辑器的内容,如下所示:

I have a page containing a PrimeFaces (2.2.1) Editor component, a Refresh button and a selectOneMenu, whose selection affects the contents of the Editor, as follows:

<p:editor id="uploadedText" value="#{facilityDataUploadBean.uploadedText}"
          width="600" height="180" disabled="true" controls="" />
<h:commandButton value="Refresh" immediate="true" />
<h:selectOneMenu id="skipLines" styleClass="dropdown"
                 value="#{facilityDataUploadBean.skipLines}">
    <f:selectItems value="#{facilityDataUploadBean.skipLinesList}" />
    <f:ajax listener="#{facilityDataUploadBean.importParameterChanged}" />
</h:selectOneMenu>

facilityDataUploadBean.importParameterChanged更新facilityDataUploadBean.uploadedText.更改selectOneMenu值后,操作员按Refresh按钮刷新页面,包括p:editor的内容. (我不能简单地使用AJAX刷新p:editor,因为至少在PF 2.2.1中它不能正确地重新渲染).

facilityDataUploadBean.importParameterChanged updates facilityDataUploadBean.uploadedText. After changing the selectOneMenu value, the operator presses the Refresh button to refresh the page, including the contents of the p:editor. (I cannot simply refresh the p:editor using AJAX, because it doesn't re-render correctly, at least in PF 2.2.1.)

当更改selectOneMenu值时,似乎应该能够自动完成页面刷新,但是我无法提出能够做到这一点的属性和事件的组合.我在selectOneMenu上尝试了onchange="submit();"immediate="true"valueChangeListener的各种组合,以及在f:ajax事件上的execute="@all/@form"render="@all/@form",都无济于事.我当前的解决方法是显示一条消息,要求用户每当更改selectOneMenu选择-漂亮的Hokey时按下Refresh按钮.

It seems like I ought to be able to accomplish the page refresh automatically when the selectOneMenu value is changed, but I've been unable to come up with a combination of attributes and events that will do that. I've tried various combinations of onchange="submit();", immediate="true" and valueChangeListener on the selectOneMenu, as well as execute="@all/@form", render="@all/@form" on the f:ajax event, all to no avail. My current workaround is to display a message asking the user to press the Refresh button whenever they change the selectOneMenu selection - pretty hokey.

推荐答案

onchange事件中调用window.location.replace(window.location.href)而不是submit(),例如:

Invoke window.location.replace(window.location.href) rather than submit() in the onchange event, as in:

<h:selectOneMenu id="skipLines" ... onchange="window.location.replace(window.location.href);">
    <f:selectItems ... />
    <f:ajax ... />
</h:selectOneMenu>

这篇关于如何在selectOneMenu选择的JSF中刷新页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆