NDeveloper
NDeveloper

Reputation: 3177

<p:calendar> not working properly while the pattern="dd-MMM-yyyy" is mentioned for locale="fr"

In my multilingual project the application is viewed in two languages: English and French. I have a date picker calendar to insert date. like:

<p:calendar id="doj" required="true" yearRange="c-100:c+100"
              value="#{userdetailsController.currentlyLoggedUser.doj}" 
              styleClass="calendar" showOn="button" label="#{prop['tum.doj.label']}" 
              navigator="true" locale="#{localeController.locale}"
              pattern="dd-MMM-yyyy">
</p:calendar>

when locale en is selected the <p:calendar> works fine. on clicking the calendar button opens the date picker calendar. But when the locale fr is selected <p:calendar> button does not work. But if I remove the pattern or make the pattern="dd-MMMM-yyyy" then it works fine. But I want to show the date in dd-MMM-yyyy pattern.

Please suggest! Thanks in advance. I am using primefaces3.5 in my application.

Upvotes: 1

Views: 2160

Answers (1)

I've tried to replicate the error without success. I've noticed, however, that when changing from en to fr locale I have 08-janv.-2013 instead of 08-Jan-2013.

Here is the sample code I've used, maybe it will help you.

Properties of a ViewScoped bean

private String locale = "en";    

private Date date = new Date();

The View

<p:growl showDetail="true" autoUpdate="true" />

<h:form>
    <p:selectOneMenu value="#{viewMBean.locale}">
        <p:ajax update="doj" />
        <f:selectItem itemLabel="FR" itemValue="fr" />
        <f:selectItem itemLabel="EN" itemValue="en" />
    </p:selectOneMenu>

    <p:calendar id="doj" required="true" yearRange="c-100:c+100" value="#{viewMBean.date}"
                styleClass="calendar" showOn="button" pattern="dd-MMM-yyyy"
                navigator="true" locale="#{viewMBean.locale}" />

    <p:commandButton value="Submit" />
</h:form>

<script>
    PrimeFaces.locales ['fr'] = {
        closeText: 'Fermer',
        prevText: 'Précédent',
        nextText: 'Suivant',
        monthNames: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
        monthNamesShort: ['Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Jun', 'Jul', 'Aoû', 'Sep', 'Oct', 'Nov', 'Déc'],
        dayNames: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'],
        dayNamesShort: ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'],
        dayNamesMin: ['D', 'L', 'M', 'M', 'J', 'V', 'S'],
        weekHeader: 'Semaine',
        firstDay: 1,
        isRTL: false,
        showMonthAfterYear: false,
        yearSuffix: '',
        timeOnlyTitle: 'Choisir l\'heure',
        timeText: 'Heure',
        hourText: 'Heures',
        minuteText: 'Minutes',
        secondText: 'Secondes',
        currentText: 'Maintenant',
        ampm: false,
        month: 'Mois',
        week: 'Semaine',
        day: 'Jour',
        allDayText: 'Toute la journée'
    };
</script>

Upvotes: 1

Related Questions