2016-01-05 79 views
0

我在下面的一個xhtml頁面中使用了primefaces日曆組件。Primefaces日曆組件中未突出顯示當前日期

<!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; 
    } 
} 

問題是,當日歷渲染,今天的日期是不突出。 如果我初始化selectedDate像下面這樣的變量,它會默認加載今天的日期,並突出顯示它。

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; 
    } 
} 

這是在primefaces中的限制嗎?有沒有其他方法可以實現這一目標?

+0

突出顯示「今天」與選擇無關。它在展示中起作用。用瀏覽器開發工具檢查你的CSS – Kukeltje

回答

0

這是一個瀏覽器問題。這是突出顯示今天的日期,如果我使用Chrome瀏覽器,但它不是與Internet Explorer。然後我按照下面的堆棧溢出討論提供的建議解決了這個問題。

IE-8 Compatible issue with Primefaces?

我加入下面頭標記中的代碼行。

<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>