ace:dateTimeEntry acessing month  XML
Forum Index -> Components
Author Message

Joined: 27/Apr/2017 06:13:52
Messages: 2


I have a simple ace:dateTimeEntry, rendered as not a popup. When I change the month there is no change in the selected value, however on the server side I need to do some work which depends on the actual month (which is shown on the screen). Is there any way to get the actual month, without clicking on a day?

For example:

<ace:dateTimeEntry id="testCalendar"
<ace:ajax event="dateSelect" execute="@this" render="@all"
listener="#{calendarBean.newDay}" />

in the bean I need something like this:
Date month;
public void setMonth(****){
month = *****;}

Thank you!

Gergely Juhasz

Joined: 21/Mar/2007 00:00:00
Messages: 177

There are no listeners or ajax events for the month change, since it only occurs in the client. However, there's a way to find out the month number by using some Javascript and the jQuery UI API. Here's some code to get you started:

 			<h:inputHidden id="monthValueHolder" value="#{bean.monthNumber}"/>
 			<h:outputText value="#{bean.monthNumber}"/>
 			<script type="text/javascript">
 					var c = ice.ace.instance('form:cal'); // client id of the ace:dateTimeEntry component
 					if (c) {
 						c.jq.datepicker('option', 'onChangeMonthYear', function(year, month) {
 							var monthValueHolder = document.getElementById('form:monthValueHolder');
 							monthValueHolder.value = month;
 							ice.s({}, monthValueHolder);

The idea is to register the onChangeMonthYear event on the jQuery UI datepicker widget (http://api.jqueryui.com/datepicker/#option-onChangeMonthYear) and use it to update a hidden field. Then, we submit the whole form. In the code above, this hidden field will be updated with the month value (1-12) and the form will be submitted, updating its value in the server, and, then, because the value is bound to an h:outputText as well, the value will be displayed on the page. What you want to do is to add a valueChangeListener to the hidden input to do whatever operation you intend to do. You still need to polish and perfect this solution, since you'll have to make sure to re-apply this script if the ace:dateTimeEntry component is reloaded on the page, but this is some good code to get you started.

Art Zambrano
ICEsoft Technologies Inc.
Forum Index -> Components
Go to:   
Powered by JForum 2.1.7ice © JForum Team