0 Replies Latest reply on Oct 31, 2008 5:24 AM by mario.balaban

    can I put something else then strings into the rich:calendar

      I'm developing an agenda using the rich:calendar. In each day cell I'd like to put a selectable and modifiable list of events of the day (similar to google calendar or the one in the teamwork project). I'm trying to put a instance of the ListaDataModel (containing objects with name property) into the HashMap used by the dataModel attribute of the calendar. Here is the code:

      <rich:calendar id="calendarAttivita" datePattern="dd/MM/yyyy"
       enableManualInput="false" popup="false" mode="ajax"
       styleClass="fontMedium" cellWidth="50px"
       <!-- Customization with usage of facets and accessible elements -->
       <f:facet name="weekDay">
       <h:panelGroup style="width:60px; overflow:hidden;" layout="block">
       <h:outputText value="{weekDayLabelShort}" />
       <f:facet name="weekNumber">
       <h:outputText value="{weekNumber}" style="color:red" />
       <f:facet name="footer">
       <h:panelGrid columns="3" width="100%"
       columnClasses="fake, width100 talign">
       <h:outputText value="{previousMonthControl}"
       style="font-weight:bold;" />
       <h:outputText value="{currentMonthControl}"
       style="font-weight:bold;" />
       <h:outputText value="{nextMonthControl}"
       style="font-weight:bold;" />
       <f:facet name="header">
       <h:outputText value="{day}" />
       <rich:dataList var="record"
       <h:outputText value="#{record.name}"></h:outputText>

      And this is the CalendarDataModel used by the attibute dataModel="#{myDataModel}"> in the calendar tag:

      public class myDataModel implements CalendarDataModel {
       public CalendarDataModelItem[] getData(Date[] arg0) {
       if (arg0 == null) {
       throw new IllegalArgumentException(
       "Null date array argument for getData.");
       CalendarDataModelItem[] items = new CalendarDataModelItem[arg0.length];
       for (int i = 0; i < arg0.length; i++) {
       items = createDataModelItem(arg0);
       return items;
       private CalendarDataModelItem createDataModelItem(Date date) {
       CalendarDataModelItemImpl item = new CalendarDataModelItemImpl();
       HashMap<String, Object> data = new HashMap<String, Object>();
       FacesContext facesContext = FacesContext.getCurrentInstance();
       ExternalContext externalContext = facesContext.getExternalContext();
       DefinitionManager definitionManager = (DefinitionManager) externalContext
       ListDataModel listDataModel = definitionManager.getScheduledJobList(date); // Here I'm retrieving the list for each day
       data.put("eachDayDataList", listDataModel);
       return item;
       public Object getToolTip(Date arg0) {
       // TODO Auto-generated method stub
       return null;
       public LavoriSchedulatiDataModel() {
       // TODO Auto-generated constructor stub

      the last class involved :
      public class CalendarDataModelItemImpl implements CalendarDataModelItem {
       HashMap<String, Object> data;
       int day;
       boolean enabled;
       Object toolTip;
       private String style;
       public Object getData() {
       // TODO Auto-generated method stub
       // return "9:00 Riunione<br/>10:00 Incontro Magistrato<br/>";
       return data;
       * Returns: day of the month on which data must be shown.
       public int getDay() {
       // TODO Auto-generated method stub
       return day;
       public String getStyleClass() {
       return style;
       public Object getToolTip() {
       return toolTip;
       public boolean hasToolTip() {
       return toolTip != null;
       public boolean isEnabled() {
       return enabled;
       * @param data
       * HashMap containing mappings like listaLavori ListaDataModel
       * containing the jobs
       public void setData(HashMap<String, Object> data) {
       this.data = data;
       public void setDay(int day) {
       this.day = day;
       public void setEnabled(boolean enabled) {
       this.enabled = enabled;
       public void setToolTip(Object toolTip) {
       this.toolTip = toolTip;
       public void setStyleClass(String style) {
       this.style = style;

      But when I use the datamodel in this manner I get :java.lang.NoSuchMethodException: Property 'volatility' has no getter method.

      So my question is:
      can I put something else then strings (collections for example) into the HashMap used by the CalendarDataModel and the use them for uicomponents inside each day cell of the calendar ?