Reputation: 59
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"/>
Upvotes: 0
Views: 2315
Reputation: 425
For me, this was solved via the example in https://www.logicbig.com/tutorials/misc/primefaces/select-one-menu-with-ajax.html
The key is that the ajax change
event isn't well supported (it does not appear to fire the update
). Using itemSelect
instead completely fixed this problem for me.
<p:ajax event="itemSelect" update="@all"/>
Upvotes: 0
Reputation: 11
I recently had the same problem and was able to solve it by adding explicit no-cache instructions to the HTTP-Header.
e.g. implement the javax.servlet.Filter class and do something like
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
httpServletResponse.setHeader("Cache-Control", "no-cache, no-store,
must-revalidate"); // HTTP 1.1.
httpServletResponse.setHeader("Pragma", "no-cache"); // HTTP 1.0.
httpServletResponse.setDateHeader("Expires", 0); // Proxies.
in the doFilter() method.
Then just apply your filter-class to the pages you want to filter in your web.xml
Upvotes: 1
Reputation: 425
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
Upvotes: 3
Reputation: 644
Check if your bean is @RequestScoped
. If so change it to @ViewScoped
.
Upvotes: 0