Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First, create in your html the place where you want the date picker to go, like so:</p> <pre><code>&lt;span id="dateBox"/&gt; </code></pre> <p>Create a new entry point, called something like Integration</p> <pre><code>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; /** * Entry point classes define &lt;code&gt;onModuleLoad()&lt;/code&gt;. */ public class Integration implements EntryPoint { @Override public void onModuleLoad() { //create date box DateBox dateBox = new DateBox(); //set the value for the form submit dateBox.getTextBox().getElement().setId("dateValueField"); //we need to override the default format dateBox.setFormat(new DateBox.DefaultFormat() { private DateTimeFormat dtf = DateTimeFormat.getFormat("MM/dd/yyyy"); @Override public void reset(DateBox dateBox, boolean abandon) { super.reset(dateBox, abandon); } @Override public Date parse(DateBox dateBox, String text, boolean reportError) { return super.parse(dateBox, text, reportError); } @Override public String format(DateBox dateBox, Date date) { if(date == null) return ""; return this.dtf.format(date); } }); //add to the span RootPanel.get("dateBox").add(dateBox); } } </code></pre> <p>You should probably put this in a new module, something like com.example.integration.Integration.gwt.xml.</p> <pre><code> &lt;module rename-to='integration'&gt; &lt;!-- Inherit the core Web Toolkit stuff. --&gt; &lt;inherits name='com.google.gwt.user.User'/&gt; &lt;inherits name='com.google.gwt.user.theme.clean.Clean'/&gt; &lt;!-- Specify the app entry point class. --&gt; &lt;entry-point class='com.example.integration.client.Integration'/&gt; &lt;!-- Specify the paths for translatable code --&gt; &lt;source path='client'/&gt; &lt;source path='shared'/&gt; &lt;/module&gt; </code></pre> <p>Now that you've done this you'll need to do the standard GWT dance to add the compiled code to your HTML. Your final HTML should look something like:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta http-equiv="content-type" content="text/html; charset=UTF-8"&gt; &lt;link type="text/css" rel="stylesheet" href="Integration.css"&gt; &lt;title&gt;Web Application Starter Project&lt;/title&gt; &lt;script type="text/javascript" language="javascript" src="integration/integration.nocache.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;!-- OPTIONAL: include this if you want history support --&gt; &lt;iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"&gt;&lt;/iframe&gt; &lt;!-- RECOMMENDED if your web app will not function without JavaScript enabled --&gt; &lt;noscript&gt; &lt;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"&gt; Your web browser must have JavaScript enabled in order for this application to display correctly. &lt;/div&gt; &lt;/noscript&gt; &lt;form id="form"&gt; &lt;!-- old style date including formatting javascript and all the old cruft --&gt; Old Style Date:&lt;input type="text" id="sometext" value="MM/DD/YYYY"/&gt;&lt;br/&gt; &lt;!-- new style. substitute your own styles and whatnot to make it not strange --&gt; New Hotness:&lt;span id="dateBox"/&gt; &lt;!-- you can submit this form as it is and it will just work (tm) --&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>There will be a form item (text input box) in your form now with the id of 'dateValueField'. This will submit just like a regular form element.</p> <p>So, some of this advice should be able to get you on your way. Good luck.</p> <p>Note, there are some smaller and easier javascript libraries (including some jQuery stuff) that can do this much easier.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload