OK, I’ve developed an XPages calendar. I’m using viewScope variables to store data like the year, month, how many days in the month and what day (mon, tue, etc) the month starts on.
At the top of the calendar I’ve got a computed field which displays the month, to the right a link which increments the month by one via the onClick event. This all works just fine (the code is below). However when I add another link to the left of the month computed field with the same code that’s in the link to the right of the computed field, with the only exception being I subtract one from the month, it screws the whole thing up where none of the viewScope variables work. I can’t figure this out, please help.
Custom Control beforePageLoad event:
viewScope.put(“dispDate”, @Now());
viewScope.put(“dispCalYear”, @Year(viewScope.get(“dispDate”)));
viewScope.put(“dispCalMonth”, @Month(viewScope.get(“dispDate”)));
viewScope.put(“daysInMonth”, new Date(viewScope.dispCalYear, viewScope.dispCalMonth, 0).getDate());
viewScope.put(“firstDayInMonth”, new Date(viewScope.dispCalYear,viewScope.dispCalMonth -1 ,1).getDay());
Month Forward by 1 link onClick event:
viewScope.put(“dispCalMonth”,@Month(viewScope.get(“dispDate”)));
viewScope.put(“dispDate”,new Date(viewScope.get(“dispCalYear”),viewScope.get(“dispCalMonth”)-1, 1));
viewScope.put(“daysInMonth”, new Date(viewScope.get(“dispCalYear”), viewScope.get(“dispCalMonth”), 0).getDate());
viewScope.put(“firstDayInMonth”, new Date(viewScope.get(“dispCalYear”),viewScope.get(“dispCalMonth”)-1,1).getDay());
Month backward by 1 onClick event:
viewScope.put(“dispCalMonth”,@Month(viewScope.get(“dispDate”)-1));
viewScope.put(“dispDate”,new Date(viewScope.get(“dispCalYear”),viewScope.get(“dispCalMonth”)-1, 1));
viewScope.put(“daysInMonth”, new Date(viewScope.get(“dispCalYear”), viewScope.get(“dispCalMonth”), 0).getDate());
viewScope.put(“firstDayInMonth”, new Date(viewScope.get(“dispCalYear”),viewScope.get(“dispCalMonth”)-1,1).getDay());
The confusing part here is, the code in the backward 1 month link is in the onClick event. Why is it having an affect on the beforePageLoad event even when a new browser window is opened and the month backward link hasn’t been clicked on? And if this is the case, why doesn’t the same thing happen in the month forward link? Maybe I should be using something other than viewScope variables?
Thanks,
Keith