2012-06-08 49 views
1

任何人都可以帮助我如何在JSF页面中添加弹出日历。我需要添加日历,其中用户将选择日期并且所选日期应显示在文本框中。任何人都可以帮助我实现丰富的人脸日历吗?将日历添加到JSF页面

回答

2

您可以使用丰富的面孔日历方式如下: -

<rich:calendar id="dtDOB" value="#{Bean.variableName}" styleClass="textBox" 
    datePattern="dd-MMM-yyyy" required="true" 
    label="#{Something}" validator="Validator.Something" /> 

VARIABLENAME将有setter和getter在你的伴奏bean.The数据类型将是日期。 所以当你真正选择一个日期并提交页面时,你的获得者将包含所选的日期。 使用 getVariableName()检索选定的值。

你的bean应该是这样的: -

@ManagedBean(name="Demo") //Annotation.You can also define this entry in faces-config.xml 
@RequestScoped //Scope of the bean 

public class TestDemo 
{ 
private Date dtDateOfBirth; 


public Date getDtDateOfBirth() { 
     return dtDateOfBirth; 
    } 

    public void setDtDateOfBirth(Date dtDateOfBirth) { 
     this.dtDateOfBirth = dtDateOfBirth; 
    } 
} 

修改后的富:历应该是这个样子: -

<rich:calendar id="dtDOB" value="#{Demo.dtDateOfBirth}" styleClass="textBox" 
    datePattern="dd-MMM-yyyy" required="true" 
    label="#{Something}" validator="Validator.Something" /> 

如果你不想使用验证删除验证器和所需的属性从富:日历标记

+0

因为我是新的春季Web流可以你帮我我应该在哪里添加setter和getter在后台bean.I没有任何想法富历工程 – bharathi

+0

我收到以下错误:/WEB-INF/flows/helloFlow/mainpage.xhtml:ELResolver无法处理标识符为'Bean'的空基对象 – bharathi

+0

答案中的Bean实际上是您的manageBean.You需要声明名称manageBean,其范围在faces-config.xml中,或者您可以使用注释。如果使用后者,则可以直接在bean上使用ManageBean属性。你的getter和setter将会在你的bean中。 – AngelsandDemons