First, create a place in your html where you want the date picker to go, for example:
<span id="dateBox"/>
Create a new entry point called Integration
package com.example.integration.client; import java.util.Date; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.ui.RootPanel; import com.google.gwt.user.datepicker.client.DateBox; public class Integration implements EntryPoint { @Override public void onModuleLoad() {
You should probably put this in a new module, for example com.example.integration.Integration.gwt.xml.
<module rename-to='integration'> <inherits name='com.google.gwt.user.User'/> <inherits name='com.google.gwt.user.theme.clean.Clean'/> <entry-point class='com.example.integration.client.Integration'/> <source path='client'/> <source path='shared'/> </module>
Now that you have done this, you will need to do a standard GWT dance to add the compiled code to your HTML. Your last HTML should look something like this:
<html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link type="text/css" rel="stylesheet" href="Integration.css"> <title>Web Application Starter Project</title> <script type="text/javascript" language="javascript" src="integration/integration.nocache.js"></script> </head> <body> <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe> <noscript> <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif"> Your web browser must have JavaScript enabled in order for this application to display correctly. </div> </noscript> <form id="form"> Old Style Date:<input type="text" id="sometext" value="MM/DD/YYYY"/><br/> New Hotness:<span id="dateBox"/> </form> </body> </html>
Your form will now have a form element (text input field) with the identifier 'dateValueField'. This will be the same as a regular form element.
So, some of these tips should be able to help you. Good luck.
Please note that there are several smaller and simpler javascript libraries (including some jQuery materials) that can make this a lot easier.
source share