Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

using jquery date picker with input field in bean  RSS feed

 
hemamalini nithyanandam
Ranch Hand
Posts: 53
Chrome Eclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an bean vacationRequestBean with startdate and enddate of date field. I used jquery date picker in my index.xhtml for those fields.
format is MM-dd-yyyy for date picker

<script>
$(function() {
$("#datepicker").datepicker();
});
</script>

and in xhtml

<h:inputText id="date" class="datepicker" value="#{vacationRequestBean.startdate }" >
<f:convertDateTime pattern="MM-dd-yyyy" type="date />
</h:inputText>

<h:inputText id="date" class="datepicker" value="#{vacationRequestBean.enddate }" >
<f:convertDateTime pattern="MM-dd-yyyy" type="date />
</h:inputText>


i am getting error as "<f:convertDateTime > Parent not an instance of ValueHolder"
how to store the value selected using jquery date picker to bean on submitting the form.
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would really recommend using one of the JSF extension classes (RichFaces, PrimeFaces, etc.) over brute-force jQuery for a date/time control. They're more JSF-friendly.

One thing I can see that's questionable in your example is the attempt to locate a DOM element with an ID of "#datepicker". JSF has 2 types of IDs. 1) The IDs that you code in your View Definition and 2) the actual (low-level) IDs that JSF generates as part of the process of rendering the View Definition into HTML.

JavaScript and HTML require the low-level ID, not the JSF ID. So it would be something more like "#form1:startDate"/
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For using datepicker in JSF, the conversion thingy isn't done in JSF, so don't use the <f:convert....>.

Instead use the datepicker to change the format according.
 
hemamalini nithyanandam
Ranch Hand
Posts: 53
Chrome Eclipse IDE MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much my code worked after removing F:convert
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!