John
John

Reputation: 660

Richfaces calendar manual input value not binding

I've got a richfaces calendar component defined as

<rich:calendar id="startDate" value="#{myBean.dateSet.startDate}" 
               timeZone="#{myBean.dateSet.timeZone}"
               datePattern="#{myBean.dateSet.datePattern}"
               enableManualInput="true" immediate="true">
      <a4j:support event="onchanged" action="#{myBean.adjustEndDate}" 
                   reRender="startDate,endDate" ajaxSingle="true" />
</rich:calendar>

when I'm changing the date using the calendar popup/gui everything is working fine.

However when I'm changing it via the input text field, the value is not being updated to myBean.dateSet.startDate, although it is being updated correctly on the calendar component itself (i.e. if I click the icon for calendar popup it shows the updated current date).

Any suggestions on how I can get it to update the value to myBean correctly?

Thanks!

Upvotes: 3

Views: 3632

Answers (3)

Sebastian
Sebastian

Reputation: 13

You can use the oninputchange event inside the rich:calendar component like Max Katz suggested.

For example:

<rich:calendar 
   ...
   oninputchange="invokeCalendarOnChange(event,'#{rich:clientId('$idOfTheCalendar')}')"
   ...
</rich:calendar>

function invokeCalendarOnChange(event, id) {
   var c = RichFaces.$(id);
   c.invokeEvent("change", RichFaces.getDomElement(c.id), event, c.selectedDate);
}

Hope that helps!

Upvotes: 1

ohseekay
ohseekay

Reputation: 805

I'm not sure if this helps, but if you want to get the value inside the input text field, you refer to it as <calId>InputDate . So in your case, the input text field will have id startDateInputDate. Hope this helps somehow!

Upvotes: 1

Max Katz
Max Katz

Reputation: 1582

Use oninputchange event, that's the one that tracks manual changes.

Upvotes: 2

Related Questions