Santhosh Lakshmanan
Santhosh Lakshmanan

Reputation: 11

Current date is not highlighted in Primefaces calendar component

I am using primefaces calendar component in one of my xhtml pages like below.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:p="http://primefaces.org/ui">

<ui:composition template="../../template/header.xhtml" >

<ui:define name="pageTitle">Primefaces Calendar</ui:define>

<ui:define name="body">
   <p:calendar value="#{dateChooserBean.selectedDate}" />
</ui:define>

</ui:composition>

DateChooserBean

import java.util.Date;

public class DateChooserBean {

    private Date selectedDate;

     public Date getSelectedDate() {
         return selectedDate;
     }

     public void setSelectedDate(Date selectedDate) {
         this.selectedDate = selectedDate;
     }
}

The problem is that today's date is not highlighted when the calendar is rendered. If I initialize the selectedDate variable like below it loads today's date by default and highlights it as well.

import java.util.Date;

public class DateChooserBean {

    **private Date selectedDate = new Date();**

    public Date getSelectedDate() {
        return selectedDate;
    }

    public void setSelectedDate(Date selectedDate) {
        this.selectedDate = selectedDate;
    }
}

Is this a limitation in primefaces? Is there any other way I can achive this?

Upvotes: 0

Views: 977

Answers (1)

Santhosh Lakshmanan
Santhosh Lakshmanan

Reputation: 11

It is a browser issue. It is highlighting the today's date if i use Chrome but it is not with internet explorer. Then i followed the suggestion provided in the below Stack Overflow discussion that solved the problem.

IE-8 Compatible issue with Primefaces?

I added below lines of code inside head tag.

   <f:facet name="first">
      <meta http-equiv="X-UA-Compatible" content="IE=edge" />
     <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
   </f:facet>

Upvotes: 0

Related Questions