Search code examples
primefacesjsf-2selectonemenu

Primefaces selectOneMenu changes value after page refresh in firefox


I am using PrimeFaces SelectOneMenu with change event call. When I change it's value, the change method calls and sets some parameters. when I refresh the page, in the bean side, selected value changes to default but in the UI, changed value showed. So, when user clicks on the submit, the setter method changes the value but change method don't calls. Here is UI code:

<p:selectOneMenu value="#{bean.selectedType}">
    <f:selectItems value="#{bean.types}"/>
    <p:ajax event="change" listener="#{bean.changeType}" update=":form"/>
</p:selectOneMenu>
<p:commandButton actionListener="#{bean.changeType}" update=":form"/>

Solution

  • I Solve this problem with remoteCommand component, to update selectOneMenu after page is refreshed. Don't forget to set selected variable to null in @PostConstruct method.

    The problem occurs only on Firefox browser.

    code:

    <p:remoteCommand name="rcName"
                     update="@form"
                     autoRun="true"
                     ignoreAutoUpdate="true" />code