There are a few more restrictions that a class must obey to allow inheritance. Constructors must not invoke overridable methods, directly or indirectly. If you violate this rule, program failure will result. The superclass constructor runs before the subclass constructor, so the overriding method in the subclass will be invoked before the subclass constructor has run. If the overriding method depends on any initialization performed by the subclass constructor, the method will not behave as expected.
there is nothing wrong with ur code once see the count of flowerbrackets are getting odd no Thanks,
pradeep
All Answers
There are a few more restrictions that a class must obey to allow inheritance. Constructors must not invoke overridable methods, directly or indirectly. If you violate this rule, program failure will result. The superclass constructor runs before the subclass constructor, so the overriding method in the subclass will be invoked before the subclass constructor has run. If the overriding method depends on any initialization performed by the subclass constructor, the method will not behave as expected.
Thanks,
pradeep
Thanks for the help.. Can u plz give a samll example in Apex...
Regards
post ur code if it is ok with u...
Thanks,
pradeep
public with sharing class CustomForecastPageControllerClass{
Map<Integer, String> mapOfMonthNumberAndMonthName = New Map<Integer, String>();
}
public CustomForecastPageControllerClass(ApexPages.StandardController controller) {
mapOfMonthNumberAndMonthName = serviceClass.constructMappingForMonthNumberAndMonth();
if(mapOfMonthNumberAndMonthName.get(getRangeStart()) != null){ ///////////////////////////error here
forecastHeader.Period__c = mapOfMonthNumberAndMonthName.get(getRangeStart());
}else{
forecastHeader.Period__c = mapOfMonthNumberAndMonthName.get(system.today().month());
}
}
public integer getRangeStart()
{
List<Period> periodList = serviceClass.getPeriodList();
map<Integer, List<Period>> fiscalMapForYear = new map<Integer, List<Period>>();
Integer year,closeDateyear;
for(Period period : PeriodList) {
year = period.StartDate.year();
if(fiscalMapForYear.get(year) != null) {
fiscalMapForYear.get(year).add(period);
} else {
fiscalMapForYear.put(year, new List<Period> {period});
}
}
closeDateyear= system.today().year();
if(fiscalMapForYear != null && fiscalMapForYear.get(closeDateyear)!= null){
for(Period period : fiscalMapForYear.get(closeDateYear)) {
if(system.today()>= period.StartDate && system.today()<= period.EndDate){
return period.number;
}
}
}
return null;
}
}
there is nothing wrong with ur code once see the count of flowerbrackets are getting odd no Thanks,
pradeep
thanks,
pradeep