RF4 Component binding problem: RichFaces is not defined
ingoschi Jul 14, 2011 8:11 AMHi,
I 'm converting a JSF 1.2 RichFaces 3.3.3 application to JSF 2.0 RichFaces 4.0.
The application uses component binding to a great extent.
I tried an example with a plain facelet with rich:calendar, which works, and with a facelet with component binding which produces javascript errors like "RichFaces is not defined" probably for RichFaces.ui.Calendar
This is my test facelet
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html">
<h:head>
    <title>test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
</h:head>
<body>
    <h:form id="form" binding="#{componentBindingCtrl.form}"/>
</body>
</html>
This is my ManagedBean
package bindingtest;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.component.html.HtmlForm;
import javax.faces.component.html.HtmlPanelGrid;
import javax.faces.context.FacesContext;
import org.richfaces.component.UICalendar;
import org.richfaces.component.UIOutputPanel;
@ManagedBean(name = "componentBindingCtrl")
@SessionScoped
public class ComponentBindingCtrl{
  
    private Date testDate = new Date();
    
    public Date getTestDate() {
        return testDate;
    }
    public void setTestDate(Date testDate) {
        this.testDate = testDate;
    }
    private HtmlForm form;
    public HtmlForm getForm() {
        return form;
    }
    public void setForm(final HtmlForm form) {
        this.form = form;
    }
    public ComponentBindingCtrl() {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ExpressionFactory expressionFactory = facesContext.getApplication()
                .getExpressionFactory();
        ELContext elContext = facesContext.getELContext();
        
        form = new HtmlForm();        
       
        HtmlPanelGrid panelgrid = new HtmlPanelGrid();
        panelgrid.setColumns(1);
        panelgrid.setBorder(0);
        form.getChildren().add(panelgrid);   
        
        UIOutputPanel panel = new UIOutputPanel();
        panel.setId("panel");
        panelgrid.getChildren().add(panel);
        
        UICalendar calendar = new UICalendar();
        calendar.setValueExpression("value", expressionFactory.createValueExpression(elContext, "#{componentBindingCtrl.testDate}", Date.class));
        calendar.setEnableManualInput(true); 
        calendar.setRequired(false);
        calendar.setId("cal");       
        calendar.setTimeZone(TimeZone.getDefault());
        calendar.setLocale(Locale.getDefault());
        panel.getChildren().add(calendar);         
    }
}
Is there something obviously wrong?
I added the whole maven project as attachment.
Regards,
Ingo
- 
            
                            
            rich4dateTest.zip 3.4 KB
 
    