Class FormComponentPanel<T>
- Type Parameters:
T
- The model object type
- All Implemented Interfaces:
Serializable
,Iterable<Component>
,IEventSink
,IEventSource
,IFeedbackContributor
,IConverterLocator
,IGenericComponent<T,
,FormComponent<T>> IMetadataContext<Serializable,
,Component> IQueueRegion
,IFormModelUpdateListener
,IFormVisitorParticipant
,ILabelProvider<String>
,IHeaderContributor
,IRequestableComponent
,IHierarchical<Component>
,IClusterable
- Direct Known Subclasses:
LocalDateTimeField
,MultiFileUploadField
,Palette
,TimeField
,ZonedDateTimeField
It is recommended that you override FormComponent.convertInput()
and let it set the value that
represents the compound value of the nested components. Often, this goes hand-in-hand with
overriding FormComponent.onBeforeRender()
, where you would analyze the model value, break it up and
distribute the appropriate values over the child components.
Here is a simple example of a panel with two components that multiplies and sets that as the master model object. Note that for this simple example, setting the model value wouldn't make sense, as the lhs and rhs cannot be known.
public class Multiply extends FormComponentPanel { private TextField left; private int lhs = 0; private int rhs = 0; private TextField right; public Multiply(String id) { super(id); init(); } public Multiply(String id, IModel model) { super(id, model); init(); } protected void convertInput() { Integer lhs = (Integer)left.getConvertedInput(); Integer rhs = (Integer)right.getConvertedInput(); setConvertedInput(lhs * rhs); } private void init() { add(left = new TextField("left", new PropertyModel(this, "lhs"), Integer.class)); add(right = new TextField("right", new PropertyModel(this, "rhs"), Integer.class)); left.setRequired(true); right.setRequired(true); } }With this markup:
<wicket:panel> <input type="text" wicket:id="left" size="2" /> * <input type="text" wicket:id="right" size="2" /> </wicket:panel>Which could be used, for example as:
add(new Multiply("multiply"), new PropertyModel(m, "multiply"))); add(new Label("multiplyLabel", new PropertyModel(m, "multiply")));and:
<span wicket:id="multiply">[multiply]</span> = <span wicket:id="multiplyLabel">[result]</span>
- Author:
- eelcohillenius
- See Also:
-
Field Summary
Fields inherited from class org.apache.wicket.markup.html.form.FormComponent
FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL, VALUE_SEPARATOR
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING, RFLAG_CONTAINER_HAS_REMOVALS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if the form component's 'required' requirement is met by first checkingFormComponent.isRequired()
to see if it has to check for requirement.void
Clears the user input.protected IMarkupSourcingStrategy
IfComponent.getMarkupSourcingStrategy()
returns null, this method will be called.protected void
Processes the component tag.Methods inherited from class org.apache.wicket.markup.html.form.FormComponent
add, add, convertInput, convertValue, error, getConvertedInput, getDefaultLabel, getDefaultLabel, getForm, getInput, getInputAsArray, getInputName, getModelValue, getParameterValues, getRawInput, getType, getValidatorKeyPrefix, getValidators, getValue, hasRawInput, inputAsInt, inputAsInt, inputAsIntArray, inputChanged, internalOnModelChanged, invalid, isInputNullable, isMultiPart, isRequired, isValid, newValidatable, newValidationError, onBeforeRender, onDetach, onDisabled, onInvalid, onValid, processChildren, processInput, remove, reportRequiredError, setConvertedInput, setLabel, setModelValue, setRequired, setType, shouldTrimInput, trim, updateAutoLabels, updateAutoLabels, updateCollectionModel, updateModel, valid, validate, validateRequired, validateValidators, visitComponentsPostOrder, visitFormComponentsPostOrder
Methods inherited from class org.apache.wicket.markup.html.form.LabeledWebMarkupContainer
getLabel
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
Methods inherited from class org.apache.wicket.MarkupContainer
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, getRegionMarkup, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onComponentTagBody, onInitialize, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, stream, streamChildren, toString, toString, visitChildren, visitChildren
Methods inherited from class org.apache.wicket.Component
add, addStateChange, beforeRender, canCallListener, canCallListenerAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, createConverter, 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, getMarkupTag, 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, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, onAfterRender, onConfigure, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, renderPart, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlForListener, urlForListener, visitParents, visitParents, warn, wrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.wicket.IGenericComponent
getDefaultModel, getDefaultModelObject, getModel, getModelObject, setDefaultModel, setDefaultModelObject, setModel, setModelObject
Methods inherited from interface org.apache.wicket.IQueueRegion
dequeue, getRegionMarkup, newDequeueContext
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
FormComponentPanel
Constructor.- Parameters:
id
- The component id
-
FormComponentPanel
Constructor.- Parameters:
id
- The component idmodel
- The component model
-
-
Method Details
-
checkRequired
Description copied from class:FormComponent
Checks if the form component's 'required' requirement is met by first checkingFormComponent.isRequired()
to see if it has to check for requirement. If that is true then by default it checks if the input is null or an empty StringStrings.isEmpty(CharSequence)
Subclasses that overwrite this method should also call
FormComponent.isRequired()
first.- Overrides:
checkRequired
in classFormComponent<T>
- Returns:
- true if the 'required' requirement is met, false otherwise
- See Also:
-
newMarkupSourcingStrategy
Description copied from class:Component
IfComponent.getMarkupSourcingStrategy()
returns null, this method will be called. By default it returns null, which means that a default markup strategy will be attached to the component.Please note that markup source strategies are not persisted. Instead they get re-created by calling this method again. That's ok since markup sourcing strategies usually do not maintain a state.
- Overrides:
newMarkupSourcingStrategy
in classComponent
- Returns:
- Markup sourcing strategy
-
onComponentTag
Description copied from class:FormComponent
Processes the component tag.- Overrides:
onComponentTag
in classFormComponent<T>
- Parameters:
tag
- Tag to modify- See Also:
-
clearInput
Description copied from class:FormComponent
Clears the user input.- Overrides:
clearInput
in classFormComponent<T>
-