lofa in
lofa in

Reputation: 317

Event for select a date on datePicker

I need to compare two calendar dates. I wrote the javascript function too. But how can I execute this function(which event?) on select a date from the datePicker? See my JSF code

<h:outputText value="From Date" />
<p:calendar id="fDate" value="#{backingBean.fDate}" mode="popup"
    showOn="button" pattern="dd/MM/yyyy">

</p:calendar>
<p:message id="fId" for="fDate" />

<h:outputText value="To Date" />
<p:calendar id="tDate" value="#{backingBean.tDate}" mode="popup"
    showOn="button" pattern="dd/MM/yyyy" ondateselected="compareDate();" />
<p:message id="tId" for="tDate" />

ondateselected="compareDate(); is not executing at all, it is wrong ,I guess. I'm using primefaces-3.0.M3 with JSF2.

Upvotes: 1

Views: 3803

Answers (1)

Daniel
Daniel

Reputation: 37061

not sure when exactly they changed it to use p:ajax , but maybe it was before 3.0M3

so try this way

<p:calendar value="#{backingBean.tDate}">
    <p:ajax event=”dateSelect” oncomplete="compareDate();return false;" />
</p:calendar>

now when i think about it again i think you can put the js function in onsuccess="" and remove the return false;

Upvotes: 3

Related Questions