I’m using RichFaces 3.3.3 and been trying to figure out how to set the Time portion of Rich:Cal to be current System date instead of the Default 12:00 where the date pattern is dd/M/yyyy HH:mm . I am also not interested using DefaultTime attribute as its no use in my situation.
so Question is : Have i missed it or it is not possible to have current system time included when user selects a date cell?
2 – If the answer to above is not possible then what is the best way to implement such behaviour.
Would below be any good :
<rich:calendar id="richCal1"
value="#{cust.dateFrom1}"
datePattern="dd/M/yyyy HH:mm"
enableManualInput="true"
<f:convertDateTime pattern="dd/M/yyyy HH:mm" type="both"/>
<f:validator validatorId="#{cust.dateAppend}"/>
<f:attribute name="richCalendar" value="RichCalendar1" />
</rich:calendar>
So when user selects a date, in Backbean custom validator dateAppend i will determine the element the trigger was fired from using the UIComponent.getAttributes() which for above code will be richCalendar and hence know which backbean variable to update to overwrite default Time with System time. Sounds Hacky but i don’t know any other way and should work.
I’m posting here so in case the above approach is totally wrong someone can let me know or offer advice on alternatives. Thanks
UPDATE:
The above approach won’t work since Setters are called at update model not at apply request phase and therefore i cannot change the value of backbean variable when the event is fired.
there must be a way. Any hints would be greatly appreciated.
You need to implement a custom CalendarDataModel and assign it as dataModel for the calendar.
calendarDataModelItem:
}