Reputation:
On my page i have form with data from database. I want to implement, as default behaviour, writing all changes to db.
I found such example
<h:selectOneMenu value="#{bean.options}" onchange="submit()"
var="#{bean.options}" valueChangeListener="#{bean.changeListernMethod}">
<f:selectItem itemValue="1" itemLabel="option1" />
<f:selectItem itemValue="2" itemLabel="option2" />
<f:selectItem itemValue="3" itemLabel="option3" />
</h:selectOneMenu>
but it not call listener method and reload all page. I can't reload page on every inputText edit or menu selection change. Do you have idea how to achieve such behaviour? Update objects in bean without page reload.
Upvotes: 1
Views: 1956
Reputation: 965
<f:ajax listener="#{bean.changeListernMethod}" render="@form" event="valueChange"/>
This is how you implement partial submit, or in your words: update objects in bean without page reload. The line I typed will fire ajax and update (only) the form whenever a value is selected and is different from the previous selected.
For more info:
https://docs.oracle.com/javaee/6/javaserverfaces/2.1/docs/vdldocs/facelets/f/ajax.html
Upvotes: 2