モバイルデバイスで実行することをターゲットにしたGWTアプリケーションがあります。input type="tel"
新しいHTML5を使用して電話入力を受け入れ、モバイルデバイスに正しいキーボード入力(数値)の入力を求めるプロンプトを表示したいと思います。
GWT TextBoxを使用しようとしていますが、正しい入力タイプでHTMLをレンダリングする方法がわかりません。
これについて何かアイデアはありますか?
前もって感謝します。
簡単な方法
TextBox tel=new TextBox();
tel.getElement().setAttribute("type", "tel");
TextBox email=new TextBox();
email.getElement().setAttribute("type", "email");
TextBox url=new TextBox();
url.getElement().setAttribute("type", "url");
カスタムウィジェットを作成します。
package com.example;
import com.google.gwt.dom.client.InputElement;
import com.google.gwt.user.client.ui.TextBoxBase;
public class TelephoneBox extends TextBoxBase {
public TelephoneBox() {
super(createTelInput());
}
private static native InputElement createTelInput() /*-{
var input = document.createElement("input");
input.setAttribute("type", "tel");
return input;
}-*/;
}
次に、UiBinderで使用できます。
<ui:UiBinder ... xmlns:my="urn:import:com.example">
...
<my:TelephoneBox/>
モバイル デバイス用の GWT であるmgwt ( http://www.m-gwt.com ) には、さまざまな入力 (電話入力も) が多数あります。あなたはそれを見たいと思うかもしれません。