Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The <code>ondateselected</code> and <code>ontimeselected</code> attributes are only invoked when the date or time is <em>actually changed</em>, not when you just click on the date or closes the time editor. There are no standard <code>&lt;rich:calendar&gt;</code> attributes which capture that. You need to override the standard <code>calendar.js</code> functions <code>eventCellOnclick()</code> (which is invoked when a date is clicked) and <code>hideTimeEditor()</code> (which is invoked when time editor is closed).</p> <p>The following works for me with RichFaces 3.3.3 (and Mojarra 1.2_15 and Tomcat 7.0.29).</p> <pre><code>&lt;h:form id="form"&gt; &lt;rich:calendar id="currentDate" popup="true" datePattern="dd/MM/yyyy - HH:mm" enableManualInput="false" showFooter="false" required="true" resetTimeOnDateSelect="true" showWeeksBar="false" showWeekDaysBar="true" value="#{bean.currentDate}" oncollapse="return this.component.timeSelected;" &gt; &lt;a4j:support event="onchange" ajaxSingle="true" /&gt; &lt;/rich:calendar&gt; &lt;/h:form&gt; &lt;script&gt; var currentDateComponent = $('form:currentDate').component; var originalCellOnClickFunction = currentDateComponent.eventCellOnClick; currentDateComponent.eventCellOnClick = function() { this.timeSelected = false; originalCellOnClickFunction.apply(this, arguments); currentDateComponent.showTimeEditor(); }; var originalHideTimeEditorFunction = currentDateComponent.hideTimeEditor; currentDateComponent.hideTimeEditor = function() { this.timeSelected = true; originalHideTimeEditorFunction.apply(this, arguments); }; &lt;/script&gt; </code></pre> <p>Note that <code>ondateselected</code>, <code>ontimeselect</code> and <code>ontimeselected</code> attributes are removed and that <code>oncollapse</code> attribute has been changed. Also note that the script must be executed after the calendar is been populated in the DOM. So the above works as-is. If you want to move the script into its own JS file (which is a good thing), make sure that it's executed on DOM ready only (i.e. put script in end of <code>&lt;body&gt;</code>, or execute it by <code>window.onload()</code> or <code>jQuery.ready()</code>).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload