unable to invoke/call backing bean from rich:calendar
cgrahamatip Jan 26, 2009 1:00 PMI am unable to trigger a backing bean method from the rich:calendar widget. I have tried using backing bean methods changeSelectedDate, changeSelectD, and changeDateValue. I have used rich:calendar attributes: currentDateChangeListener="#{calendarBean.changeSelectedDate}" and valueChangeListener="#{calendarBean.changeDateValue}">
in different combinations with no success.
I have the following page and backing bean code:
snippet of page code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<html>
<f:view>
<f:loadBundle basename="com.ipi.InformationPortal.util.prompts" var="prompts"/>
<head>
<title><h:outputText value="#{prompts.formTitle}"/></title>
<link href="css/mdpMaster.css" rel="stylesheet" type="text/css" />
</head>
<body>
<%@include file="inc/ip_header.jsp" %>
<div id="mdpContainer">
<h:panelGrid id="Calpanel" columns="3" width="50%" >
<a4j:outputPanel id="calendar" layout="block">
<rich:calendar value="#{calendarBean.selectedDate}"
locale="#{calendarBean.locale}"
popup="#{calendarBean.popup}"
datePattern="#{calendarBean.pattern}"
showApplyButton="#{calendarBean.showApply}"
valueChangeListener="#{calendarBean.changeDateValue}">
<a4j:support event="oncurrentdateselected" action="#{calendarBean.changeDateValue}"/>
<a4j:support event="ondateselected" action="#{calendarBean.changeSelectedDate}"/>
</rich:calendar>
</a4j:outputPanel>
</h:panelGrid>
</div> <!-- end #container -->
<%@include file="inc/ip_footer.jsp" %>
</body>
</f:view>
</html>
Backing Bean code:
import org.richfaces.event.CurrentDateChangeEvent;
import java.util.Date;
import java.util.Locale;
import javax.faces.event.ValueChangeEvent;
public class CalendarBean {
String defaultLocale = "en, US";
Boolean enableManualInput = false;
Locale locale = new Locale(defaultLocale);
String pattern = "yyyy-MM-dd";
Boolean popup = true;
Date selectedDate = DateUtils.getPreviousDate();
Boolean showInput = true;
Boolean showApply = false;
public void changeSelectedDate(CurrentDateChangeEvent event) {
System.out.print("CalendarBean::changeSelectedDate --> called "+event);
//return "Go figure";
}
public void changeSelectedD() {
System.out.print("CalendarBean::changeSelectedD --> called ");
//return "Go figure";
}
public void changeDateValue(ValueChangeEvent event) {
System.out.print("CalendarBean::changeDateValue --> called ");
}
public Boolean getEnableManualInput() {
return enableManualInput;
}
public void setEnableManualInput(Boolean enableManualInput) {
this.enableManualInput = enableManualInput;
}
public Locale getLocale() {
return locale;
}
public void setLocale(Locale locale) {
this.locale = locale;
}
public String getPattern() {
return pattern;
}
public void setPattern(String pattern) {
this.pattern = pattern;
}
public Boolean getPopup() {
return popup;
}
public void setPopup(Boolean popup) {
this.popup = popup;
}
public Date getSelectedDate() {
return selectedDate;
}
public void setSelectedDate(Date selectedDate) {
this.selectedDate = selectedDate;
}
public Boolean getShowApply() {
return showApply;
}
public void setShowApply(Boolean showApply) {
this.showApply = showApply;
}
public Boolean getShowInput() {
return showInput;
}
public void setShowInput(Boolean showInput) {
this.showInput = showInput;
}
public void valueChanged(ValueChangeEvent event) {
System.out.println("CalendarBean::valueChanged was called -->> WOW"+event);
}
}
In an attempt to see if the a4j:support event is being triggered i used the following:
<a4j:outputPanel id="calendar" layout="block">
<rich:calendar value="#{calendarBean.selectedDate}"
locale="#{calendarBean.locale}"
popup="#{calendarBean.popup}"
datePattern="#{calendarBean.pattern}"
showApplyButton="#{calendarBean.showApply}"
valueChangeListener="#{calendarBean.changeDateValue}">
<a4j:support event="onchanged" action="alert('Value succesfully stored')"/>
</rich:calendar>
</a4j:outputPanel>
I don't get an alert window.
I am using richfaces version 3.3.0GA. What am I missing??