Reinitialize the current month name, when i click button
- by EswaraMoorthyNEC
Hi,In my richCalendar.jsp page, first time i click the showCurrentMonth button and display the current month using rich:calendar.
i select some other month
i click SelectedMonth button. I show the selected month name.
My problem is :
I go to any other page. then i come visit the richCalendar.jsp and again click showCurrentMonth button, this time the rich:calendar show the already selected month instead of current month .
Each time, i want to show current month when i click showCurrentMonth.
richCalendar.jsp
<body>
<h:form id="calendarForm" binding="#{CalenderBean.initForm}">
<rich:panel>
<a4j:outputPanel id="calendarOutputPanel">
<h:panelGrid>
<a4j:commandButton value="showCurrentMonth"
action="#{CalenderBean.showCurrentMonthAction}"
reRender="monthlyPanelGridId,monthlyCalendarId,calendarOutputPanel"/>
<h:panelGrid id="monthlyPanelGridId" rendered="#{CalenderBean.monthlyCalendarRendered}" >
<rich:calendar boundaryDatesMode="scroll"
id="monthlyCalendarId"
showWeekDaysBar="false"
oncurrentdateselected="event.rich.component.selectDate(event.rich.date)"
showFooter="false"
popup="false"
value="#{CalenderBean.selectedMonth}"/>
</h:panelGrid>
<h:panelGrid id = "SearchButtonGrid">
<a4j:commandButton id="SelectedMonth"
value="SelectedMonth"
action="#{CalenderBean.selectedMonthButtonAction}"
reRender="calendarOutputPanel"/>
<h:outputText value="#{CalenderBean.selectedMonthName}" />
</h:panelGrid>
</h:panelGrid>
</a4j:outputPanel>
<rich:panel></h:form></body>
CalenderBean.java
import java.util.Calendar;
import java.util.Date;
import javax.faces.component.html.HtmlForm;
public class CalenderBean
{
private HtmlForm initForm;
private boolean monthlyCalendarRendered;
private Date selectedMonth;
private String selectedMonthName;
public CalenderBean()
{
}
public String showCurrentMonthAction()
{
monthlyCalendarRendered = true;
Calendar calendar = Calendar.getInstance();
int startingDate = calendar.getActualMinimum(Calendar.DAY_OF_MONTH);
calendar.set(Calendar.DATE, startingDate);
selectedMonth = calendar.getTime();
return "";
}
public String selectedMonthButtonAction()
{
selectedMonthName = selectedMonth.toString();
return "";
}
public HtmlForm getInitForm()
{
selectedMonth = null;
monthlyCalendarRendered = false;
return initForm;
}
public void setInitForm(HtmlForm initForm){
this.initForm = initForm;
}
public boolean isMonthlyCalendarRendered(){
return monthlyCalendarRendered;
}
public void setMonthlyCalendarRendered(boolean monthlyCalendarRendered){
this.monthlyCalendarRendered = monthlyCalendarRendered;
}
public Date getSelectedMonth(){
return selectedMonth;
}
public void setSelectedMonth(Date selectedMonth){
this.selectedMonth = selectedMonth;
}
public String getSelectedMonthName(){
return selectedMonthName;
}
public void setSelectedMonthName(String selectedMonthName){
this.selectedMonthName = selectedMonthName;
}
}
First time i visit this page perfectly show the current month. Then i go to any othe page and then come to see this page, click showCurrentMonth button not show the current month.
Help me.
Thanks in advance.