I am using PF RC1, JSF 2.0.
When I click on the today button of p:calendar, by default it highlights the today’s date, but the requirement is if i click on “Today” button i should get the highlighted date (today’s date) in the respective text field.
This doesn’t seem to work in the show case also. http://www.primefaces.org/showcase-labs/ui/calendarButtonPanel.jsf
Is it possible to write a custom code on Today button or make today button work as explained above.
Thanks.
Basically you would need to do a jQuery bind of an event handler to the Today button on the popup. This button can be found easily enough using a specific jQuery UI class.
The problem comes within the handler for the click event, because you would need to somehow trigger a select event from within the popup and there are some challenges to doing this. The first problem that I ran into is that the Datepicker javascript object doesn’t seem to have a meaningful or predictable id for me to find it. I am sure there is a way I am just not seeing it yet.
Once you have found this JS object you can call the
_selectDayfunction on it passing the following arguments…Where
cal_inputis the id of the Calendar components text field, the second and third arguments I assume are month and year respectively, then the fourth argument I assume is the Datepicker itself.Even if this were to work, there are existing jQuery UI bugs regarding select events not firing on the datepicker that Primefaces utilizes for its Calendar component. http://forum.primefaces.org/viewtopic.php?f=3&t=9301 This could impact the ability to do this as well.
I know this isn’t a clear answer but it is a difficult problem, and I hope this gives you some insight.