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

查看:20
本文介绍了如何在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:ajaxexecute="@all/@form"render="@all/@form"/code> 事件,都无济于事.我目前的解决方法是显示一条消息,要求用户在更改 selectOneMenu 选择时按下刷新按钮 - 非常糟糕.

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.

推荐答案

Invoke window.location.replace(window.location.href) 而不是 submit()onchange 事件,如:

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天全站免登陆