
public class HtmlLayoutContainer extends AbstractHtmlLayoutContainer
HtmlData.
Code Snippet #1 - The first code snippet is a simple example that uses
in-line HTML:
public interface HtmlLayoutContainerTemplate extends XTemplates {
@XTemplate("<div><div class='cell1'></div><div class='cell2'></div><div class='cell3'></div></div>")
SafeHtml getTemplate();
}
private void onModuleLoad() {
HtmlLayoutContainerTemplate templates = GWT.create(HtmlLayoutContainerTemplate.class);
HtmlLayoutContainer c = new HtmlLayoutContainer(templates.getTemplate());
c.add(new TextButton("Button 1"), new HtmlData(".cell1"));
c.add(new TextButton("Button 2"), new HtmlData(".cell2"));
c.add(new TextButton("Button 3"), new HtmlData(".cell3"));
Viewport v = new Viewport();
v.add(c);
RootPanel.get().add(v);
}
Code Snippet #2 - The second code snippet is more complex and illustrates the
use of external HTML and CSS files:
public interface CodeSnippetStyle extends CssResource {
String cell1();
String cell2();
String cell3();
}
public interface CodeSnippetHtml extends XTemplates {
@XTemplate(source = "CodeSnippet.html")
SafeHtml getTemplate(CodeSnippetStyle style);
}
public interface CodeSnippetCss extends ClientBundle {
@Source("CodeSnippet.css")
CodeSnippetStyle style();
}
private void onModuleLoad() {
CodeSnippetHtml html = GWT.create(CodeSnippetHtml.class);
CodeSnippetCss css = GWT.create(CodeSnippetCss.class);
css.style().ensureInjected();
HtmlLayoutContainer c = new HtmlLayoutContainer(html.getTemplate(css.style()));
c.add(new Label("Label 1"), new HtmlData("." + css.style().cell1()));
c.add(new Label("Label 2"), new HtmlData("." + css.style().cell2()));
c.add(new Label("Label 3"), new HtmlData("." + css.style().cell3()));
Viewport v = new Viewport();
v.add(c);
RootPanel.get().add(v);
}
By default, GWT generates short, obfuscated names for the injected CSS. For
debugging purposes, instruct GWT to generate recognizable style names by
including the following in the module file (.gwt.xml).
<set-configuration-property name='CssResource.style' value='pretty' />
CodeSnippet.html contains the HTML, for example:
<div>
<div class="{style.cell1}"></div>
<div class="{style.cell2}"></div>
<div class="{style.cell3}"></div>
</div>
CodeSnippet.css contains the styles, for example:
.cell1 {
background-color: #ffffcc;
}
.cell2 {
background-color: #ccffff;
}
.cell3 {
background-color: #ffccff;
}
AbstractHtmlLayoutContainer.HtmlDataUIObject.DebugIdImpl, UIObject.DebugIdImplEnabledHasWidgets.ForIsWidgetIndexedPanel.ForIsWidgetDEBUG_ID_PREFIX| Constructor and Description |
|---|
HtmlLayoutContainer(SafeHtml html)
Creates an HTML layout container using the specified HTML template.
|
HtmlLayoutContainer(String html)
Creates an HTML layout container using the specified HTML template.
|
| Modifier and Type | Method and Description |
|---|---|
SafeHtml |
getHTML() |
void |
setHTML(SafeHtml html) |
void |
setHTML(String html)
Sets the HTML template for the layout container.
|
addadd, add, addAddHandler, addBeforeAddHandler, addBeforeRemoveHandler, addContainerHandler, addRemoveHandler, clear, disable, enable, findWidget, getItemByItemId, getWidget, getWidgetCount, getWidgetIndex, getWidgetIndex, iterator, remove, remove, removeaddBeforeHideHandler, addBeforeShowContextMenuHandler, addBeforeShowHandler, addBlurHandler, addDisableHandler, addEnableHandler, addFocusHandler, addHideHandler, addMoveHandler, addResizeHandler, addShowContextMenuHandler, addShowHandler, addStyleOnOver, clearSizeCache, disableEvents, enableEvents, fireEvent, focus, getData, getElement, getFocusSupport, getHideMode, getId, getItemId, getOffsetHeight, getOffsetWidth, getShadow, getShadowPosition, getStateId, getTabIndex, getToolTip, hide, hideToolTip, isAllowTextSelection, isAutoHeight, isAutoWidth, isDeferHeight, isEnabled, isRendered, isStateful, isVisible, isVisible, mask, mask, onBrowserEvent, removeToolTip, setAllowTextSelection, setBorders, setBounds, setBounds, setContextMenu, setData, setDeferHeight, setEnabled, setHeight, setHeight, setHideMode, setId, setItemId, setPagePosition, setPixelSize, setPosition, setShadow, setShadowPosition, setSize, setStateful, setStateId, setTabIndex, setToolTip, setToolTip, setToolTipConfig, setVisible, setWidth, setWidth, show, sync, syncSize, unmaskaddAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, getLayoutData, getParent, isAttached, removeFromParent, setLayoutData, sinkEvents, unsinkEventsaddStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, removeStyleDependentName, removeStyleName, setStyleDependentName, setStyleName, setStyleName, setStylePrimaryName, setTitle, setVisible, sinkBitlessEvent, toStringpublic HtmlLayoutContainer(SafeHtml html)
html - the HTML representation of the layout containerpublic HtmlLayoutContainer(String html)
html - the HTML representation of the layout containerCopyright © 2015. All rights reserved.