Reputation: 1821
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}" />
Upvotes: 0
Views: 3867
Reputation: 37061
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"..... />
Upvotes: 2