您可以定義自定義CalendarDataModel,使其返回週五和週六有一定的CSS類,如
public class CalendarModelItem implements CalendarDataModelItem {
//rest of code
private String styleClass;
public void setStyleClass(String styleClass) { this.styleClass = styleClass; }
public String getStyleClass() { return styleClass; }
//rest of code
}
public class CalendarModel implements CalendarDataModel {
//rest of code
public CalendarDataModelItem[] getData(Date[] dateArray) {
CalendarDataModelItem[] modelItems = new CalendarModelItem[dateArray.length];
Calendar c = Calendar.getInstance();
for (Date d : dateArray) {
c.setTime(d);
CalendarModelItem modelItem = new CalendarModelItem();
if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY || calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) {
modelItem.setStyleClass("weekend");
} else {
modelItem.setStyleClass("");
}
modelItems[i] = modelItem;
}
return modelItems;
}
//rest of code
}
定義自定義CSS類和復位由富歷冬青
.rich-calendar-holly{
background-color:white;
color:black;
}
.weekend {
background-color: #FFEBDA;
}
格式化
,然後在日曆組件使用
<rich:calendar ... dataModel="#{calendarModel}" />
產生額外的細節:我灣t從週六,週日到週五和週六更改週末 –