【问题标题】:Current date is not highlighted in Primefaces calendar componentPrimefaces 日历组件中未突出显示当前日期
【发布时间】:2016-01-05 14:28:41
【问题描述】:

我在我的一个 xhtml 页面中使用 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的限制吗?还有其他方法可以实现吗?

【问题讨论】:

  • 突出显示“今天”与选择无关。它在陈列柜中工作。使用浏览器开发工具检查你的 CSS

标签: jsf primefaces calendar


【解决方案1】:

这是一个浏览器问题。如果我使用 Chrome,它会突出显示今天的日期,但不是使用 Internet Explorer。然后我按照下面的 Stack Overflow 讨论中提供的建议解决了这个问题。

IE-8 Compatible issue with Primefaces?

我在 head 标签内添加了以下代码行。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-06
    相关资源
    最近更新 更多