Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapping inputText to Date object in JSF

Tags:

java

jsf

I am very new to JSF. I am trying to get a Date in JSF inpuText component using a custom datepicker( made using jquery and cannot user calendar component). I want to map this inputText to a Java Date object in the bean (which will eventually stored as Date in DB). One way to achieve this is to keep String in bean and write converters in getters and setters, which doesn't look nice to me. Is there any recommended approach to solve this problem. Any help/hints/links are appreciated.

like image 741
Umer Hayat Avatar asked May 22 '12 09:05

Umer Hayat


1 Answers

You can try like this

<h:inputText value="#{backingBean.someDate}">  
   <f:convertDateTime pattern="yyyy-MM-dd"/>  
</h:inputText>

where someDate is a util date & have accessor methods in the backing bean.

like image 74
Nayan Wadekar Avatar answered Oct 22 '22 07:10

Nayan Wadekar