Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rich:calendar ignored format pattern for the day of the week after selecting

As a part of , I am using component with settled value of datePattern as follows:

<rich:calendar id="effectiveDate" 
value="#{itemBean.effectiveDate}" 
datePattern="EEEE, MM/dd/yyyy" />

So when I load the form, the existing effectiveDate from the requested itemBean is properly displayed in the text field.

Problems:

  1. when clicking on calendar icon, the content of the text field will be gone. So if I didn't select anything from the calendar popup, then the text field remains empty.

  2. when the date is selected it is displayed like that (for example):

EEEE, 11/19/2012 So the week day is not displayed properly.

Noticed that without specifying the week day (EEEE part of datePattern) none of mentioned above problems occurs.

Is there some specific way to display the week day after selecting?

I am on RichFaces 4.2.2.

Thanks!

like image 852
user1801069 Avatar asked Dec 10 '25 07:12

user1801069


1 Answers

As I think this is a known issue with <rich:calendar>. I don't know much about that.
However try this,

<rich:calendar id="effectiveDate" value="#{itemBean.effectiveDate}" onchanged="formatCalendarString(event, this);" datePattern="EEEE, MM/dd/yyyy" />

Within <head></head> tags put this.

<head>
    <script>
        function formatCalendarString(event, cal) {
            var date = new Date(Date.parse(event.rich.component.getSelectedDate()));
            var weekdays=new Array(7);
            weekdays[0]='Sunday';
            weekdays[1]='Monday';
            weekdays[2]='Tuesday';
            weekdays[3]='Wednesday';
            weekdays[4]='Thursday';
            weekdays[5]='Friday';
            weekdays[6]='Saturday';

            var day = weekdays[date.getDay()];
            if(typeof(day) !== 'undefined') {
              var formattedDate = (day + ', ') + event.rich.component.getSelectedDateString().substring(6);
              cal.value = formattedDate;
            }
        }
    </script>
</head>
like image 158
prageeth Avatar answered Dec 13 '25 14:12

prageeth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!