So I think straight JQuery is pretty easy, although I have not tried the new JQuery plugin(s). Just download JQuery and JQuery UI and include them on your page.
<script type="text/javascript" src="<c:url value="/scripts/jquery/jquery-1.2.6.js"/>"></script>
<script type="text/javascript" src="<c:url value="/scripts/jquery/jquery.ui.all.js"/>"></script>
Then pick a JQuery UI Theme, download it and include it as well:
<link type="text/css" href="<c:url value="/scripts/jquery/theme/ui.theme.css"/>" rel="stylesheet" />
You are almost all set:
Include the following javascript:
$(document).ready(function(){
$(".datefield").datepicker();
});
I usually do this in a .js file that included on all pages.
Now create a struts text field and include the cssStyle 'datefield'.
<s:textfield name="mydate" cssStyle="datefield"/>
Viola!
You will likely want to create a Date converter. You can find lots of posts and discussions about Type Conversion and date converters.
Richard Gundersen-2 wrote:
Hi
I'm trying to get the datetimepicker working in my app. It's Struts 2
but it's totally non-AJAX at the moment. I also don't know anything
about AJAX to make matters worse.
Please could someone tell me
a) what extra jars (dojo/json etc) do I need to pop into WEB-INF?
I don't mind which provider I use (Dojo, Prototype etc) as long as it
works.
b) any other config to add to struts.xml?
c) JSP tags (in addition to <s:datetimepicker>) such as <s:head
and <s:url
I've read quite a few articles saying how easy it is, but they all do
things slightly differently. If someone could tell me how to get the
basics configured, so that my datetimepicker works, I'd be grateful.
Thanks