Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    #16
    That is fair enough! Thanks a lot

    Comment


      #17
      Hallo,

      In latest build getVisibleStart/EndDate() both return void! Is this done on purpose?

      Also in my RestDataSource when I do criteria.addCriteria("currentDate",getChosenDate());

      The server gets the date value decreased by one day!!

      Is this a bug on nightly build?

      Comment


        #18
        getVisibleStart and end date should indeed return dates - this was a bug in the build you're looking at. We've fixed it and the fix will show up in nightly builds dated Aug 25 or higher.

        We're not sure from your description what the problem is with the RestDataSource, but most likely it's some kind of timezone issue.
        We have a thorough description of how SmartGWT handles timezones here: http://smartclient.com/smartgwtee-la...ndStorage.html
        If this doesn't give you enough information to get things working, or you think there's an actual bug, please show us exactly how to reproduce the problem (how the criteria are being set in your code and where you're seeing incorrect date values).

        Thanks
        Isomorphic Software

        Comment


          #19
          Hallo,

          I can not understand how a TimeZone issue would take my datetime exactly one day back always as 21:00 o'clock. The funny thing is that on the client say I am doing an SC.say just to see what is inside the getChosenDate and it is correct but on the server side when the parameter arrives it is one day back see code below to replicate issue:

          Code:
          public class ReservationCalendar extends Calendar {
          
          	private Dictionary messages;
          	private CalendarDataSource eventDS;
          
          	public ReservationCalendar(Dictionary dict, CalendarDataSource eventDS) {
          		super();
          		this.messages = dict;
          		this.eventDS = eventDS;
          
          		loadUI();
          	}
          	
          	private void loadUI() {
          		setDataSource(eventDS);  
          
          		setTimeFormatter(TimeDisplayFormat.TO24HOURTIME);           
          		//use european based DD/MM/YYYY date formats   
          		setDateFormatter(DateDisplayFormat.TOEUROPEANSHORTDATE); 
          
          		setUseAllDataSourceFields(false);
          		setShowQuickEventDialog(false);
          		setShowWeekends(true);
          		
          		addDateChangedHandler(new DateChangedHandler() {			
          			@Override
          			public void onDateChanged(DateChangedEvent event) {
          				reloadCalendarData();
          			}
          		});
          
          
          		//calendar.setDataFetchMode(FetchMode.PAGED); // important    
          		//calendar.setDataPageSize(75); // important
          		setShowMonthView(false);
          		setInitialCriteria(getFetchCriteria());
          		setAutoFetchData(true);
          				
          		loadEditorDialog();				
          		selectTab(0);
          		
          		setWidth(700);
          		setHeight(500);
          	}
          	
          	private void loadEditorDialog() {
                  SelectItem reservationType = new SelectItem();   
                  reservationType.setDefaultToFirstOption(true);
                  reservationType.setTitle(messages.get("reservationFormData_type"));   
                  reservationType.setWidth(270);
                  reservationType.setDefaultToFirstOption(true);   
                  reservationType.setValueMap(messages.get("reservationType_secret"),messages.get("reservationType_friendly"),messages.get("reservationType_lesson"));
                  reservationType.setValue(messages.get("reservationType_secret"));
          
                  SelectItem reservationName = new SelectItem();  
                  reservationName.setDefaultToFirstOption(true);
                  reservationName.setName("name");   
                  reservationName.setTitle("Reservation Name");   
                  reservationName.setWidth(270);   
                  reservationName.setDefaultToFirstOption(true);   
                  reservationName.setValueMap("Name 1","Name 2","Name 3");        
          
          		setEventEditorFields(reservationName,reservationType);
          		setEventDialogFields(reservationName,reservationType);
          	}
          	
          	
          
          	private Criteria getFetchCriteria(){
          		Criteria cri = new Criteria();
          
          		if ( getChosenDate() == null )
          			cri.addCriteria("currentDate",new Date());
          		else {
          			SC.say("I AM SENDING: "+getChosenDate());
          			cri.addCriteria("currentDate",getChosenDate());
          		}
          		//cri.addCriteria("startDate",calendar.getVisibleStartDate());
          		//cri.addCriteria("endDate",calendar.getVisibleStartDate());
          
          		if ( getCurrentViewName() != null )
          			cri.addCriteria("currentView",getCurrentViewName().toString());
          		else 
          			cri.addCriteria("currentView",ViewName.WEEK.toString());			
          		return cri;
          	}
          	
          	public void reloadCalendarData() { // on current view
          		fetchData(getFetchCriteria(), new DSCallback() {
          			@Override
          			public void execute(DSResponse response, Object rawData, DSRequest request) {
          				setData(response.getData());				
          			}
          		});
          	}
          }
          MyDataSource:
          Code:
          public class CalendarDataSource extends RestDataSource {
          	
          	public CalendarDataSource() {
          		setDataFormat(DSDataFormat.JSON);         
          		
          		loadOperationBindings();		
          		loadFields();
          	}
          	
          	private void loadOperationBindings() {
          		// FETCH URL:
          		setFetchDataURL("/cas/reservationasync/listReservations.html");          
          		OperationBinding fetch = new OperationBinding();           
          		fetch.setOperationType(DSOperationType.FETCH);           
          		fetch.setDataProtocol(DSProtocol.GETPARAMS);
          		 		
          		// ADD URL:
          		setAddDataURL("/cas/reservationasync/addReservation.html");
          		OperationBinding add = new OperationBinding();   
          		add.setOperationType(DSOperationType.ADD);   
          		add.setDataProtocol(DSProtocol.GETPARAMS);   
          		
          		// UPDATE URL:
          		setUpdateDataURL("/cas/reservationasync/updateReservation.html");
          		OperationBinding update = new OperationBinding();   
          		update.setOperationType(DSOperationType.UPDATE);   
          		update.setDataProtocol(DSProtocol.GETPARAMS);   
          
          		// REMOVE URL:
          		setUpdateDataURL("/cas/reservationasync/removeReservation.html");
          		OperationBinding remove = new OperationBinding();   
          		remove.setOperationType(DSOperationType.UPDATE);   
          		remove.setDataProtocol(DSProtocol.GETPARAMS);   
          
          		setOperationBindings(fetch,add,update,remove);
          	}
          	
          	private void loadFields() {
                  DataSourceSequenceField eventIdField = new DataSourceSequenceField("eventId");   
                  eventIdField.setPrimaryKey(true);   
            
                  DataSourceTextField nameField = new DataSourceTextField("name");    
                  DataSourceTextField descField = new DataSourceTextField("description"); 
                  DataSourceDateTimeField startDateField = new DataSourceDateTimeField("startDate");   
                  DataSourceDateTimeField endDateField = new DataSourceDateTimeField("endDate");   
          
                  DataSourceTextField reservationType = new DataSourceTextField("reservationType");
                  DataSourceTextField placeType = new DataSourceTextField("placeType");   
                  DataSourceIntegerField duration = new DataSourceIntegerField("duration");   
          
                  DataSourceTextField member1Name = new DataSourceTextField("member1");
                  DataSourceTextField member2Name = new DataSourceTextField("member2");
                  DataSourceTextField member3Name = new DataSourceTextField("member3");
                  DataSourceTextField member4Name = new DataSourceTextField("member4");
                  
                  setFields(eventIdField, nameField, descField, startDateField, endDateField, reservationType, placeType, duration, member1Name, member2Name, member3Name, member4Name);
          	}	
          }
          And on the server side when I go and select date 26 Aug 2012
          SC.say on client side says it is:

          Sun Aug 26 00:00:00 GMT+300 2012

          and on server side I get:

          /cas/reservationasync/listReservations.html?currentDate=2012-08-25T21:00:00

          that is one day back!!!!

          also strange thing is that it is always 21:00 o'clock!! any ideas?
          I am in GMT+3 if this makes sense

          Thanks

          Comment


            #20
            After some more investigation I have seen that at the first time when the calendar is initially loaded the server get the chosen date correctly, the bug is whenever the user changes the date from the datepicker or the arrows and onDateChanged is called, then the server always get the one day back date!

            Any ideas?
            Also I could not figure out how to limit the hourly range of the calendar for example I want to show hours from 08:00 until 23:00 how can I do that?

            Comment


              #21
              Hallo again,

              Actually it was a TimeZone issue! It seams that everything is transferred in GMT format and is displayed to browser specific TimeZone, now my question is: How can I make the Calendar always use GMT+2 and not the browser specific time?

              Also two more questions:
              1. In my Calendar I need to display times from 08:00 to 23:00 is this possible or only 24hour format is supported?
              2. I also need to display quarters in the grid not only hour and half hour is this possible and how?

              Thanks a lot

              Comment


                #22
                Timezone setting: see DateUtil.setDisplayTimezone().

                1. don't follow - you see to be saying you want 24 hour times, and 24 hour times are supported, so.. ?

                2. it's not currently possible to change the grid lines but you can allow dragging at finer granularity via calendar.eventSnapGap (default 30).

                Comment


                  #23
                  Hallo

                  Thanks for the reply, regarding 1 yes I know I can display 24 hour times but I also want to display working hours only. It is pointless for me to display hours from 00:00 to 08:00 cause there will never occur events at these times! So I want to customize my calendar so that it only displays a time range in week and day view something like:

                  Code:
                  Calendar.setDisplayTimeRange("08:00","23:00")
                  Is this possible yet?
                  Regarding 2 do you have any idea when wil this feature be available?
                  Thanks a lot
                  Last edited by gehatg; 26 Aug 2012, 02:03.

                  Comment


                    #24
                    Adding to the above one question more:

                    What will happen if I use DateUtil.setDisplayTimezone() at onModuleLoad and then the user browses the calendar back to a date with DST? Does it take this into account? So do I have to set the setDisplayTimezone without taking into account daylight savings?

                    Thanks

                    Comment


                      #25
                      Hallo again,

                      Regarding my first question about working hours I found a couple of functions but they dont work:

                      Code:
                      cal.setShowWorkday(true);  
                      cal.setScrollToWorkday(true);
                      cal.setWorkdays(new int[]{0,1,2,3,4,5,6}); // I WANT TO USE WEEKENDS AS WELL
                      cal.setWorkdayStart("08:00am");
                      cal.setWorkdayEnd("11:30pm");
                      The above code does not allow me to create events on weekends (Saturdays/Sundays are shown disabled) and it does not scroll to to working hours as well! I am using latest 3.0p nightly build, as 3.1d has some display issues on events. Am I doing something wrong? Please see my whole calendar code below:

                      Code:
                      public class ReservationCalendar extends Calendar {
                      
                      	private Dictionary messages;
                      	private CalendarDataSource eventDS;
                      
                      	public ReservationCalendar(Dictionary dict, CalendarDataSource eventDS) {
                      		super();
                      		this.messages = dict;
                      		this.eventDS = eventDS;
                      
                      		loadUI();
                      	}
                      	
                      	private void loadUI() {
                      		setDataSource(eventDS);  
                      
                      		setTimeFormatter(TimeDisplayFormat.TO24HOURTIME);           
                      		//use european based DD/MM/YYYY date formats   
                      		setDateFormatter(DateDisplayFormat.TOEUROPEANSHORTDATE); 
                      		
                      		setUseAllDataSourceFields(false);
                      		setShowQuickEventDialog(false);
                      		setShowWorkday(true);  
                      setScrollToWorkday(true);
                      setWorkdays(new int[]{0,1,2,3,4,5,6}); // I WANT TO USE WEEKENDS AS WELL
                      setWorkdayStart("08:00am");
                      setWorkdayEnd("11:30pm");
                              
                      		addDateChangedHandler(new DateChangedHandler() {			
                      			@Override
                      			public void onDateChanged(DateChangedEvent event) {
                      				reloadCalendarData();
                      			}
                      		});
                      
                      
                      		//calendar.setDataFetchMode(FetchMode.PAGED); // important    
                      		//calendar.setDataPageSize(75); // important
                      		setShowMonthView(false);
                      		setInitialCriteria(getFetchCriteria());
                      		setAutoFetchData(true);
                      		
                      		loadEditorDialog();				
                      		selectTab(0);
                      		
                      		setWidth(700);
                      		setHeight(500);
                      	}
                      	
                      	private void loadEditorDialog() {
                              SelectItem reservationType = new SelectItem();   
                              reservationType.setDefaultToFirstOption(true);
                              reservationType.setTitle(messages.get("reservationFormData_type"));   
                              reservationType.setWidth(270);
                              reservationType.setDefaultToFirstOption(true);   
                              reservationType.setValueMap(messages.get("reservationType_secret"),messages.get("reservationType_friendly"),messages.get("reservationType_lesson"));
                              reservationType.setValue(messages.get("reservationType_secret"));
                      
                              SelectItem reservationName = new SelectItem();  
                              reservationName.setDefaultToFirstOption(true);
                              reservationName.setName("name");   
                              reservationName.setTitle("Reservation Name");   
                              reservationName.setWidth(270);   
                              reservationName.setDefaultToFirstOption(true);   
                              reservationName.setValueMap("Name 1","Name 2","Name 3");        
                      
                      		setEventEditorFields(reservationName,reservationType);
                      		setEventDialogFields(reservationName,reservationType);
                      	}
                      	
                      	private Criteria getFetchCriteria(){
                      		Criteria cri = new Criteria();
                      
                      		if ( getChosenDate() == null )
                      			cri.addCriteria("currentDate",new Date());
                      		else {
                      			//SC.say("I AM SENDING: "+getChosenDate());
                      			cri.addCriteria("currentDate",getChosenDate());
                      		}
                      		//cri.addCriteria("startDate",calendar.getVisibleStartDate());
                      		//cri.addCriteria("endDate",calendar.getVisibleStartDate());
                      
                      		if ( getCurrentViewName() != null )
                      			cri.addCriteria("currentView",getCurrentViewName().toString());
                      		else 
                      			cri.addCriteria("currentView",ViewName.WEEK.toString());			
                      		return cri;
                      	}
                      	
                      	public void reloadCalendarData() { // on current view
                      		//SC.say("I AM FETCHING: "+getChosenDate());
                      		fetchData(getFetchCriteria(), new DSCallback() {
                      			@Override
                      			public void execute(DSResponse response, Object rawData, DSRequest request) {
                      				setData(response.getData());				
                      			}
                      		});
                      	}
                      }

                      Comment


                        #26
                        Hi again,

                        And sorry for all these posts as I am still new on smargwt and I am finding out things all the time! So I found code that partially works, it seams that setWordayStart("08:00am") should be set as 24hour based like setWorkStart("08:00"), and it now displays the workdays, also I had to use setDisableWeekends(false) to enable editing the weekends.

                        Ofcourse this code only highlights the workdays and you can still make events outside the workdays range, is it possible to completely hide what is outside the workday time range?

                        Another new issue I found is that setScrollToWorkday does not work on the first shown view (dayview in my case) but it works on other views (weekview in my case), please see code below how I use it just in case am I doing anything wrong. Is it a bug with setScrollToWorkday or I am not using selectTab correctly?

                        Code:
                        import java.util.Date;
                        
                        public class ReservationCalendar extends Calendar {
                        
                        	private Dictionary messages;
                        	private CalendarDataSource eventDS;
                        
                        	public ReservationCalendar(Dictionary dict, CalendarDataSource eventDS) {
                        		super();
                        		this.messages = dict;
                        		this.eventDS = eventDS;
                        
                        		loadUI();
                        	}
                        	
                        	private void loadUI() {
                        		setDataSource(eventDS);  
                        
                        		setTimeFormatter(TimeDisplayFormat.TOSHORT24HOURTIME);   
                        
                        		//use european based DD/MM/YYYY date formats   
                        		setDateFormatter(DateDisplayFormat.TOEUROPEANSHORTDATE); 
                        		
                        		setUseAllDataSourceFields(false);
                        		setShowQuickEventDialog(false);
                        		setShowWeekends(true);
                        		setDisableWeekends(false);
                                setWorkdays(new int[]{0,1,2,3,4,5,6});
                                setWorkdayStart("08:00");
                                setWorkdayEnd("23:30");
                                
                        		addDateChangedHandler(new DateChangedHandler() {			
                        			@Override
                        			public void onDateChanged(DateChangedEvent event) {
                        				reloadCalendarData();
                        			}
                        		});
                        
                        
                        		//calendar.setDataFetchMode(FetchMode.PAGED); // important    
                        		//calendar.setDataPageSize(75); // important
                        		setScrollToWorkday(true);
                        		setShowMonthView(false);
                        		setShowWorkday(true);  
                                
                        		setInitialCriteria(getFetchCriteria());
                        		setAutoFetchData(true);
                        		
                        		loadEditorDialog();				
                        		
                        		setScrollToWorkday(true);
                        		selectTab(0);
                        		setScrollToWorkday(true);
                        
                        		setWidth(700);
                        		setHeight(500);
                        	}
                        	
                        	private void loadEditorDialog() {
                                SelectItem reservationType = new SelectItem();   
                                reservationType.setDefaultToFirstOption(true);
                                reservationType.setTitle(messages.get("reservationFormData_type"));   
                                reservationType.setWidth(270);
                                reservationType.setDefaultToFirstOption(true);   
                                reservationType.setValueMap(messages.get("reservationType_secret"),messages.get("reservationType_friendly"),messages.get("reservationType_lesson"));
                                reservationType.setValue(messages.get("reservationType_secret"));
                        
                                SelectItem reservationName = new SelectItem();  
                                reservationName.setDefaultToFirstOption(true);
                                reservationName.setName("name");   
                                reservationName.setTitle("Reservation Name");   
                                reservationName.setWidth(270);   
                                reservationName.setDefaultToFirstOption(true);   
                                reservationName.setValueMap("Name 1","Name 2","Name 3");        
                        
                        		setEventEditorFields(reservationName,reservationType);
                        		setEventDialogFields(reservationName,reservationType);
                        	}
                        	
                        	private Criteria getFetchCriteria(){
                        		Criteria cri = new Criteria();
                        
                        		if ( getChosenDate() == null )
                        			cri.addCriteria("currentDate",new Date());
                        		else {
                        			//SC.say("I AM SENDING: "+getChosenDate());
                        			cri.addCriteria("currentDate",getChosenDate());
                        		}
                        		//cri.addCriteria("startDate",calendar.getVisibleStartDate());
                        		//cri.addCriteria("endDate",calendar.getVisibleStartDate());
                        
                        		if ( getCurrentViewName() != null )
                        			cri.addCriteria("currentView",getCurrentViewName().toString());
                        		else 
                        			cri.addCriteria("currentView",ViewName.WEEK.toString());			
                        		return cri;
                        	}
                        	
                        	public void reloadCalendarData() { // on current view
                        		//SC.say("I AM FETCHING: "+getChosenDate());
                        		fetchData(getFetchCriteria(), new DSCallback() {
                        			@Override
                        			public void execute(DSResponse response, Object rawData, DSRequest request) {
                        				setData(response.getData());				
                        			}
                        		});
                        	}
                        }

                        Comment


                          #27
                          Don't call selectTab at all, call setCurrentViewName().

                          There's no way to hide non-workday hours completely, but a BackgroundClickHandler can cancel() the event to avoid a new event being added.

                          Comment


                            #28
                            Thanks for your help!

                            I just replaced selectTab(0) with setCurrentViewName(ViewName.DAY) and the same effect, it does not scroll my day view to the workday start hour! Is this a bug? I am using latest 3.0p.

                            Thanks for the BackgroundClickHandler tip ti works good with cancel()

                            Comment


                              #29
                              Hallo again,

                              I think that this is a general initialization error. I added a refresh button just above my calendar and whenever I click it I am simply invoking the following function:

                              Code:
                              public void reloadCalendarData() { // on current view
                              		
                              		fetchData(getFetchCriteria(), new DSCallback() {
                              			@Override
                              			public void execute(DSResponse response, Object rawData, DSRequest request) {
                              				setData(response.getData());	
                              				// THIS IS ONLY CALLED AFTER I CHANGE TAB AND GO FROM DATE VIEW TO WEEK VIEW AND BACK TO DATE VIEW, NOT AFTER FIST LOAD
                              			}
                              		});
                              	}
                              What happens is that at the first time that my page is loaded execute does not seem to be called at all. If I change tab and go from day view to week view scroll a little bit the week view and then back to day view it works as expected and execute is called!!

                              Another thought was that maybe I am doing something wrong in the way that I am loading the module (I am putting the calendar in a div of my struts 2 application):

                              Code:
                              RootPanel.get("calendarContainer").add(layout);
                              Am I doing something wrong, on initailization?

                              Thanks
                              Last edited by gehatg; 27 Aug 2012, 02:18.

                              Comment


                                #30
                                I just replaced

                                Code:
                                RootPanel.get("calendarContainer").add(layout);
                                with this

                                Code:
                                layout.setHtmlElement(DOM.getElementById("calendarContainer"));
                                layout.draw();
                                and the scrolling issue is gone! It now works OK! BUT I still have the reloadData-fetchData error. I can not fetchData until I go to another tab and scroll down a little bit the scroll bar, as explained on previous post.

                                Does it deal with any caching mechanism you may have?

                                Thanks

                                Comment

                                Working...
                                X