私はGWTプロジェクトを持っていますが、GWTがHTML5をどのように作成するのか疑問に思っています鬼ごっこ。
何時間も検索してここに来て尋ねた後、GWTでHTML5セクションタグを作成する方法はありますか?
はい、独自のウィジェットを作成できます。
public class SectionPanel extends ComplexPanel implements
InsertPanel.ForIsWidget {
/**
* Creates an empty section panel.
*/
public SectionPanel() {
setElement(DOM.createElement("section"));
}
/**
* Adds a new child widget to the panel.
*
* @param w
* the widget to be added
*/
@Override
public void add(Widget w) {
add(w, getElement());
}
... etc. ...
}
新しいウィジェットタイプを作成する必要はありません。ジェネリックを使用して、使用するHTMLPanel
タグを指定するだけです。
UiBinderオプション
を使用するUiBinder
と、.ui.xml
ファイルには次のようなものが含まれます。
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
...
<g:HTMLPanel tag="section">
(your section content here)
</g:HTMLPanel>
...
</ui:UiBinder>
手動オプション
プログラムでそれを行うことを好む場合:
HTMLPanel section = new HTMLPanel("section", "(your section content here)");
最初の引数は、使用するタグを指定します。最初の引数を指定しない場合のデフォルトはですdiv
。
どちらの場合も、HTML出力でこれを生成します。
<section>
(your section content here)
</section>
Ui:Binderで好きなHTMLを追加できます:
https://developers.google.com/web-toolkit/doc/latest/DevGuideUiBinder