Class WFieldLayout
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.AbstractContainer
-
- com.github.bordertech.wcomponents.AbstractNamingContextContainer
-
- com.github.bordertech.wcomponents.WFieldLayout
-
- All Implemented Interfaces:
AjaxTarget,Container,Marginable,NamingContextable,SubordinateTarget,WComponent,WebComponent,Serializable
public class WFieldLayout extends AbstractNamingContextContainer implements AjaxTarget, SubordinateTarget, Marginable
This component is used to group together a collection of
WFieldcomponents to provide a consistent layout template.It also provides some helpful infrastructure around WComponent validation by supplying helper methods to validate and set error indicators on each of its contained
WFieldcomponents. It is up the the parentValidatableComponentor aValidatingActionto call the validate() and showErrorIndicator() methods on this component.- Author:
- Adam Millard
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWFieldLayout.FieldLayoutModelHolds the extrinsic state information of the component.-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractWComponent
AbstractWComponent.WComponentRef
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_LABEL_WIDTHDeprecated.Will be defined by the theme.static StringLAYOUT_FLATLayout type of flat.static StringLAYOUT_STACKEDLayout type of stacked.-
Fields inherited from interface com.github.bordertech.wcomponents.WComponent
DEFAULT_APPLICATION_ID, DEFAULT_INTERNAL_ID, DEFAULT_NO_ID, ID_CONTEXT_SEPERATOR, ID_FRAMEWORK_ASSIGNED_SEPERATOR, ID_VALIDATION_PATTERN
-
-
Constructor Summary
Constructors Constructor Description WFieldLayout()Creates a WFieldLayout with the default layout type ofLAYOUT_FLAT.WFieldLayout(String layout)Creates a WFieldLayout with the given layout type.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description WFieldaddField(WButton button)Add a field consisting of a WButton with a null label.WFieldaddField(WLabel label, WComponent field)Add a field using the label and components passed in.WFieldaddField(String label, WComponent field)Add a field using the label and components passed in.protected WFieldLayout.FieldLayoutModelgetComponentModel()Returns the effective component model for this component.intgetLabelWidth()StringgetLayoutType()Get the type of layout for this field layout.MargingetMargin()Get the margin for the component, or null if not set.protected WFieldLayout.FieldLayoutModelgetOrCreateComponentModel()Retrieves the model for this component so that it can be modified.intgetOrderedOffset()Allows layouts to have its ordered numbering start from an offset.StringgetTitle()Get the title for this field layout.booleanisOrdered()protected WFieldLayout.FieldLayoutModelnewComponentModel()Creates a new Component model.voidremove(WComponent child)voidsetHeading(String heading)Deprecated.usesetTitle(String)insteadvoidsetLabelWidth(int labelWidth)Sets the label width.voidsetMargin(Margin margin)Set the margin for the component, or null for no margin.voidsetOrdered(boolean ordered)Flag a layout to be an ordered list.voidsetOrderedOffset(int orderedOffset)Set the starting offset for an ordered layout.voidsetTitle(String title)Set the title for the field layout.StringtoString()Creates a String representation of this component; usually for debugging purposes.-
Methods inherited from class com.github.bordertech.wcomponents.AbstractNamingContextContainer
getNamingContextId, isNamingContext, setNamingContext
-
Methods inherited from class com.github.bordertech.wcomponents.AbstractContainer
getChildAt, getChildCount, getChildren, getIndexOfChild
-
Methods inherited from class com.github.bordertech.wcomponents.AbstractWComponent
addHtmlClass, addHtmlClass, addNotify, afterPaint, assertAddSupported, beforePaint, createErrorDiagnostic, createErrorDiagnostic, forward, getAccessibleText, getAttribute, getBaseUrl, getDefaultModel, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getScratchMap, getTabIndex, getTag, getTemplate, getTemplateMarkUp, getToolTip, handleRequest, hasNoComponentModel, hasTabIndex, initialiseComponentModel, invokeLater, invokeLaters, isDebugStructure, isDefaultState, isFlagSet, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, paintComponent, preparePaint, preparePaintComponent, removeAttribute, removeComponentModel, removeHtmlClass, removeHtmlClass, removeNotify, replaceWComponent, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFlag, setFocussed, setHidden, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showErrorIndicatorsForComponent, showWarningIndicators, showWarningIndicatorsForComponent, tidyUpUIContext, tidyUpUIContextForTree, validate, validateComponent, writeReplace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.bordertech.wcomponents.Container
getChildAt, getChildCount, getChildren, getIndexOfChild
-
Methods inherited from interface com.github.bordertech.wcomponents.WComponent
addHtmlClass, addHtmlClass, forward, getAccessibleText, getAttribute, getBaseUrl, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getTabIndex, getTag, getToolTip, handleRequest, hasTabIndex, invokeLater, isDefaultState, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, preparePaint, removeAttribute, removeHtmlClass, removeHtmlClass, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFocussed, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showWarningIndicators, tidyUpUIContextForTree, validate
-
-
-
-
Field Detail
-
DEFAULT_LABEL_WIDTH
@Deprecated public static final int DEFAULT_LABEL_WIDTH
Deprecated.Will be defined by the theme. SetlabelWidth<=0 for the default.The default label width.- See Also:
- Constant Field Values
-
LAYOUT_FLAT
public static final String LAYOUT_FLAT
Layout type of flat.- See Also:
- Constant Field Values
-
LAYOUT_STACKED
public static final String LAYOUT_STACKED
Layout type of stacked.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
WFieldLayout
public WFieldLayout()
Creates a WFieldLayout with the default layout type ofLAYOUT_FLAT.
-
WFieldLayout
public WFieldLayout(String layout)
Creates a WFieldLayout with the given layout type.- Parameters:
layout- one ofLAYOUT_FLATorLAYOUT_STACKED.
-
-
Method Detail
-
setHeading
@Deprecated public void setHeading(String heading)
Deprecated.usesetTitle(String)insteadSet the heading for the field layout.- Parameters:
heading- the text for the heading
-
setTitle
public void setTitle(String title)
Set the title for the field layout.- Parameters:
title- the text for the title
-
getTitle
public String getTitle()
Get the title for this field layout.- Returns:
- the title
-
getLayoutType
public String getLayoutType()
Get the type of layout for this field layout.- Returns:
- the layout type
-
getLabelWidth
public int getLabelWidth()
- Returns:
- Returns the labelWidth.
-
setLabelWidth
public void setLabelWidth(int labelWidth)
Sets the label width.- Parameters:
labelWidth- the percentage width, or <= 0 to use the default field width.
-
setMargin
public void setMargin(Margin margin)
Set the margin for the component, or null for no margin.- Specified by:
setMarginin interfaceMarginable- Parameters:
margin- the margin for the component
-
getMargin
public Margin getMargin()
Get the margin for the component, or null if not set.- Specified by:
getMarginin interfaceMarginable- Returns:
- the margin for the component, or null if not set
-
isOrdered
public boolean isOrdered()
- Returns:
- true if ordered layout
-
setOrdered
public void setOrdered(boolean ordered)
Flag a layout to be an ordered list. Used withsetOrderedOffset(int).- Parameters:
ordered- true if ordered layout
-
getOrderedOffset
public int getOrderedOffset()
Allows layouts to have its ordered numbering start from an offset. Used withsetOrdered(boolean).- Returns:
- the ordered start offset.
-
setOrderedOffset
public void setOrderedOffset(int orderedOffset)
Set the starting offset for an ordered layout. Used withsetOrdered(boolean).- Parameters:
orderedOffset- the ordered start offset. Must be 1 or greater.
-
addField
public WField addField(String label, WComponent field)
Add a field using the label and components passed in.- Parameters:
label- the label to use for the fieldfield- the component to use for the field- Returns:
- the field which was added to the layout.
-
addField
public WField addField(WLabel label, WComponent field)
Add a field using the label and components passed in.- Parameters:
label- the label to use for the fieldfield- the component to use for the field- Returns:
- the field which was added to the layout.
-
addField
public WField addField(WButton button)
Add a field consisting of a WButton with a null label.- Parameters:
button- the WButton to add to the layout.- Returns:
- the field added to the layout.
-
remove
public void remove(WComponent child)
-
toString
public String toString()
Description copied from class:AbstractWComponentCreates a String representation of this component; usually for debugging purposes.- Overrides:
toStringin classAbstractWComponent- Returns:
- a String representation of this component, for debugging purposes.
-
newComponentModel
protected WFieldLayout.FieldLayoutModel newComponentModel()
Creates a new Component model.- Overrides:
newComponentModelin classAbstractWComponent- Returns:
- a new FieldLayoutModel.
-
getComponentModel
protected WFieldLayout.FieldLayoutModel getComponentModel()
Returns the effective component model for this component. Subclass may override this method to narrow the return type to their specific model type.- Overrides:
getComponentModelin classAbstractWComponent- Returns:
- the effective component model
-
getOrCreateComponentModel
protected WFieldLayout.FieldLayoutModel getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified. If this method is called during request processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override this method to narrow the return type to their specific model type.- Overrides:
getOrCreateComponentModelin classAbstractWComponent- Returns:
- the model for this component
-
-