cancel
Showing results for 
Search instead for 
Did you mean: 

OnStartDateChanged?

Former Member
0 Kudos

Hi to All..

In Datenavigator property, I want detail explanation abt OnStartDateChanged() event. Pleas explain in your own words with example...

URs GS

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

hi Satish,

When you click on two arrows that are displayed on either side of the DateNavigator for moving the view to the previous and the forward Months that are displayed on the view,this action gets triggered.

If you are writing a calender Planner application.This might be vital because there could be a scenario where you display all the public holidays in the Months that are getting displayed above.This information would change dynamically when you move towards the forward or the backward months.

For managing the context for the above purpose one would require this event

Regards

Amit

Former Member
0 Kudos

Hi kesari..

Can u give me an example code for this?

Urs GS

Former Member
0 Kudos

Hi Satish,

Well here's the code to implement the above scenario:

Suppose you have a xml or a resource bundle file that would give you the all the holidays within a range of date :

I leave it to you to write that file and parser.

This file gives you a method which takes 2 java.sql.date parameters and returns you a map which contains:Date object as a key and String Object as an ocassion.

Now comming back to WD:

Place a Date Navigator Control and create action for the OnStartDateChange Action Say startDateChange()

It'll give an event handler on for this which gets triggerd when you click on the navigation arrow:

Also create the context Node (say Holidays) that would have 2 Attributes in this case one of type java.util.Date(representing Day) and another one of type String

(representing Occasion).

Now comming to the code:

To set the DateNavigator to the current Date

in WDDoModifyView()


IWDDateNavigator dateNavigator = (IWDDateNavigator)view.getElement("DateNavigator");
 if(firstTime){
  dateNavigator.setFirstSelectedDate((new java.sql.Date((new Date()).getTime())));
    }

Now create a context attribute which would be a flag of type boolean in this case:

wheneve the Action is triggered : set this attribute to true(from the onStartDateChanged event handler method)

again comming back to the wdDoModifyView()


if(wdContext.currentContextElement().getFlag()){
     	java.sql.Date startDate= dateNavigator.getStartsWith();
// This will give you the start date in the java.sql format you must be aware of what
// are the changes to be made to convert it java.util.date get 
// Now getting the range date which is 3 months by default in this case
// I leave it to your creativity to calculate the end Date because there can 2 things 
// required to be  tackled 
// 1> Number of days based on the end Month.
// 2> If there is an year transaction at the same time.
// Should be quite simple.Mostly involves logic.
// Suppose you construct a new date in this case called end date
           java.util.Date endDate /// based on above calculation.
// call the parser method you've deviced which returns you a map as said.
// Say HolidayList.
Map holidayList = parserMethod(startDate,endDate);
Iterator i = holidayList.entrySet().iterator();
while(i.hasNext()){
      Map.Entry mapObject = (Map.Entry)i.next();
    IPrivateDsadView.IHolidaysNode node = wdContext.nodeHolidays();
	node.invalidate();
	IPrivateDsadView.IHolidaysElement nodeElement = node.createHolidaysElement();
	nodeElement.setDate((Date)mapObject.getKey());
	nodeElement.setHolidayName((String)mapObject.getValue());     
        node.addElement(nodeElement);
}
}

I think the above code and explanation has enough description.

If you have any confusion revert back.

Regards

Amit