I'm trying to get a value from my calendar via ajax.
xhtml portion:
<p:calendar
id="newSimFrom"
value="#{SimModel.from}" <!-- this works -->
showOn="button"
mask="true"
pattern="dd.MM.yyyy"
>
<p:ajax event="dateSelect" process="@this" update="newSimUnt" listener="#{SimController.simFromChanged()}" />
</p:calendar>
controller:
public void simFromChanged(SelectEvent se) {
log.info("called");
log.info(""+se.getObject());
//this is temporary till I can figure out what's even going on
}
But I get nothing, no event seems to be fired.
I've also tried event="change"
as well as event="select"
and process="@this"
(latter as suggested by https://stackoverflow.com/a/42295586)
Also, I've tried to put the listener on with and without the parenthesises, didn't seem to make any differences.
The calendar is inside a form tag. (Kinda, there's 2 layers if <div>
above, does that make a difference?) (https://stackoverflow.com/a/17213127/7591918)
Any ideas where I should go to for debugging what's going on? I'm relatively new to Primefaces and JSF as a whole, my IDE's console and my browser console don't give me any errors.
Thanks!
So Apparently, my problem was with how Spring internally addresses classes, or rather how the automatic name generation works, as I did not explicitly name the bean.
listener="#{SimController.newSimFromChanged}"
was changed to
listener="#{simController.newSimFromChanged}"
(note the lowercase s)
And now it works.
This is pretty unintuitive (IMO), and I'm not sure this is universally applicable but I'm going to leave this here if someone else ever has the same problem. Do note that this also does not apply if your class starts with multiple uppercase letters, if I had named my class SIMController
it would have worked right away.