public class BSGrid extends BSContainer<BSGrid>
Componente para gerar grids do bootstrap de forma programática (sem ter que escrever HTML). Este componente é bem leve, sem comportamentos extras. Ele foi criado para quando você quiser utilizar uma grid para fazer algum layout um pouco mais refinado, pois você consegue ter as referências para todas as tags geradas (podendo adicionar CSS específico em cada uma, por exemplo).
Os métodos desta API que geram containers (grids, rows, cols) podem ser utilizados de duas formas:
A forma procedural resulta em um código mais natural se você precisa guardar referências para os containers, por exemplo, para ter controle fino da renderização de respostas Ajax.
BSGrid grid = new BSGrid("grid");
grid.setAddContainerFluidClass(true);
BSRow row = grid.newRow();
row.newCol(2)
.tag("span", new Label("span1", "[col-md-2]"));
row.newCol(4)
.tag("span", new Label("span2", "[col-md-4]"));
BSCol col3 = row.newCol();
col3.md(2).sm(4);
col3.tag("span", new Label("span3", "[col-md-2 col-sm-4]"));
BSCol col4 = row.newCol();
col4.md(4).sm(8);
col4.tag("span", new Label("span4", "[col-md-4 col-sm-8]"));
A forma declarativa resulta em um código hierarquizado, semelhante à estrutura do HTML que será gerada:
new BSGrid("grid").setAddContainerFluidClass(true)
.row(r -> r
.col(2, "span", new Label("span1", "[col-md-2]"))
.col(4, "span", new Label("span2", "[col-md-4]"))
.col(2, c -> c
.sm(4)
.tag("span", new Label("span3", "[col-md-2 col-sm-4]"))
)
.col(4, c -> {
c.sm(8);
c.tag("span", new Label("span4", "[col-md-4 col-sm-8]"));
})
)
Ambos os códigos acima geram algo do tipo:
<div class="container-fluid"> <div class="row"> <div class="col-md-2"><span>[col-md-2]</span></div> <div class="col-md-4"><span>[col-md-4]</span></div> <div class="col-md-2 col-sm-4"><span>[col-md-2 col-sm-4]</span></div> <div class="col-md-4 col-sm-8"><span>[col-md-4 col-sm-8]</span></div> </div> </div>
Ambos os estilos são válidos, e podem ser misturados de acordo com a necessidade.
| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_COLS |
itemsENABLE, FLAG_AFTER_RENDERING, FLAG_INITIALIZED, FLAG_PREPARED_FOR_RENDER, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RENDERING, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING| Constructor and Description |
|---|
BSGrid(String id) |
BSGrid(String id,
org.apache.wicket.model.IModel<?> model) |
| Modifier and Type | Method and Description |
|---|---|
BSGrid |
add(org.apache.wicket.behavior.Behavior... behaviors) |
BSGrid |
appendRow(IBSComponentFactory<BSRow> factory) |
BSGrid |
appendRow1Col(IBSComponentFactory<BSCol> factory) |
IBSGridCol.BSGridSize |
getDefaultGridSize() |
BSCol |
newColInRow() |
BSCol |
newColInRow(int colspan) |
BSRow |
newRow() |
<R extends BSRow> |
newRow(IBiFunction<String,IBSGridCol.BSGridSize,R> factory) |
BSGrid |
setAddContainerClass(boolean add) |
BSGrid |
setAddContainerFluidClass(boolean add) |
BSGrid |
setDefaultGridSize(IBSGridCol.BSGridSize defaultGridSize) |
addInfoMessage, appendComponent, appendGrid, appendTag, appendTag, appendTag, getCssClass, getInnerStyle, getItems, getTagName, newChildId, newComponent, newFormGroup, newFormGroup, newGrid, newTag, newTag, newTagWithFactory, newTemplateTag, onComponentTag, onInitialize, removeItem, setCssClass, setInnerStyle, setTagNamegetRegionMarkup, newMarkupSourcingStrategygetWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSessionadd, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findComponentToDequeue, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onAfterRenderChildren, onComponentTagBody, onDetach, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, swap, toString, toString, visitChildren, visitChildren, visitChildren, visitChildrenaddStateChange, afterRender, beforeRender, canCallListenerInterface, canCallListenerInterfaceAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, debug, detach, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalOnModelChanged, internalPrepareForRender, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, onAfterRender, onBeforeRender, onConfigure, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, prepareForRender, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderHead, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setRequestFlag, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, visitParents, warn, wrapclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic static final int MAX_COLS
public BSGrid(String id)
public BSGrid(String id, org.apache.wicket.model.IModel<?> model)
public IBSGridCol.BSGridSize getDefaultGridSize()
public BSGrid setDefaultGridSize(IBSGridCol.BSGridSize defaultGridSize)
public BSRow newRow()
public <R extends BSRow> R newRow(IBiFunction<String,IBSGridCol.BSGridSize,R> factory)
public BSGrid appendRow(IBSComponentFactory<BSRow> factory)
public BSGrid appendRow1Col(IBSComponentFactory<BSCol> factory)
public BSCol newColInRow()
public BSCol newColInRow(int colspan)
public BSGrid setAddContainerClass(boolean add)
public BSGrid setAddContainerFluidClass(boolean add)
public BSGrid add(org.apache.wicket.behavior.Behavior... behaviors)
add in class org.apache.wicket.ComponentCopyright © 2018. All rights reserved.