How to refresh page in JSF on selectOneMenu selection?

jsf-2, primefaces

Solution

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>

Problem

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` 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.) 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.

Original source

Related problems