I have a PrimeFaces inputSwitch:
<p:inputSwitch id="snoozeSwitch" value="#{dashBController.snooze}" valueChangeListener="#{dashBController.updateSnoozeStatus}">
<p:ajax listener="#{dashBController.updateSnoozeStatus}" update="msgSnooze" />
</p:inputSwitch>
Now I want to give this switch an initial value from my DB. I get the value with:
@PostConstruct
public void init() {
if (!FacesContext.getCurrentInstance().isPostback()) {
snooze = getSnoozeStatus();
}
}
But I have trouble to update the old value with the new one.
public void updateSnoozeStatus() {
if(snooze == true) {
DBconnector.updateSnooze("true");
} else {
DBconnector.updateSnooze("false");
}
}
The problem: My app always uses the inital value and so the switch is stucking on the state it has originally. Maybe @BalusC knows the answer :)