0 Replies Latest reply: May 29, 2009 9:01 AM by Bouanani Meher RSS

Disabling dates in <rich:calendar> with using dataModel

Bouanani Meher Newbie

I'm trying to disable some specific dates using the dataModel methode but it doesn't work . can some one help me please and tell me where is the problem !!! thanks

package com.entity.wf;

import java.util.Date;
import java.util.Calendar;
import org.jboss.seam.annotations.Name;
import org.richfaces.model.CalendarDataModel;
import org.richfaces.model.CalendarDataModelItem;
@Name("DataModelDisabling")
public class DataModelDisabling implements CalendarDataModel {

 private Date[] dateArray;
 private Date CurrentDate;
 private CalendarDataModelItem[] items ;

 @SuppressWarnings("deprecation")
 public void injectDate(){
 Date d = new Date(2009,07,1);
 Date d2 = new Date(2009,07,4);
 Date[] daterep ;
 daterep = new Date[]{d,d2};
 setDateArray(daterep);

 }
 @Override
 public CalendarDataModelItem[] getData(Date[] dateArray) {
 if (dateArray == null) {
 System.out.println("hy i'm heeeeere");
 Date d = new Date(2009,07,1);
 Date d2 = new Date(2009,07,4);
 Date[] daterep ;
 daterep = new Date[]{d,d2};
 setDateArray(daterep);
 }
 if (items==null) {
 items = new CalendarDataModelItem[getDateArray().length];
 for (int i = 0; i < getDateArray().length; i++) {
 items = createDataModelItem(getDateArray());
 }
 }
 return items;
 }
 protected CalendarDataModelItem createDataModelItem(Date date) {
 DataModelItemImpl item = new DataModelItemImpl();
 Calendar c = Calendar.getInstance();
 c.setTime(date);
 item.setDay(c.get(Calendar.DAY_OF_MONTH));
 item.setEnabled(false);
 return item;
 }
 @Override
 public Object getToolTip(Date arg0) {
 // TODO Auto-generated method stub
 return null;
 }

 public void setDateArray(Date[] dateArray) {
 this.dateArray = dateArray;
 }

 public Date[] getDateArray() {
 return dateArray ;
 }

 public void setCurrentDate(Date currentDate) {
 CurrentDate = currentDate;
 }

 public Date getCurrentDate() {
 return CurrentDate;
 }

 public void setItems(CalendarDataModelItem[] items) {
 this.items = items;
 }

 public CalendarDataModelItem[] getItems() {
 return items;
 }

}


i'm using seam 2.1.1.GA as a framework to run my application