0

I want to bind a date with a calendar control after a specific value is selected from an autocomplete. But the following exception occurs : javax.servlet.ServletException: java.util.Date cannot be cast to javax.faces.component.UIComponent

<p:autoComplete value="#{rechargeCustomerBean.school.schoolName}" completeMethod="#{rechargeCustomerBean.completeSchool}" required="true" />

<p:calendar mode="popup"
        navigator="true" pattern="dd-MM-yyyy" effect="fadeIn"
        showButtonPanel="true"
        binding="#{rechargeCustomerBean.school.expiryDate}" />
Ammar
  • 1,811
  • 5
  • 26
  • 60
  • binding attribute should be given an el expression that maps to a server side UIComponent instance in a backing bean. You specified a Date type object. It should be object of type Calendar. From this object you need to get the date in the bean – rags May 18 '12 at 06:50

2 Answers2

2

Are you sure you want to bind?

Use the value attribute instead.

Also, add <p:ajax to your calendar to update the calendar and you are ready to go. like this

<p:autoComplete value="#{rechargeCustomerBean.school.schoolName}" completeMethod="#{rechargeCustomerBean.completeSchool}" required="true">
    <p:ajax event="itemSelect" update="idOfCalendar" /> 
</p:autoComplete>

Change

binding="#{rechargeCustomerBean.school.expiryDate}" 

into

value="#{rechargeCustomerBean.school.expiryDate}"

so it will look like this

<p:calendar value="#{rechargeCustomerBean.school.expiryDate}" id="idOfCalendar"..... />
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Daniel
  • 36,833
  • 10
  • 119
  • 200
0

use of binding attribute in <p:calender> might cause the problem...try chaging it with value=#{...}

also make sure your bean's "expiryDate" is of type Util.Date

hope this could resolve your problem..for detailed explanation see here

Community
  • 1
  • 1
Mango
  • 650
  • 2
  • 16
  • 38