Class FormComponentPanel<T>

  extended by org.apache.wicket.Component
      extended by org.apache.wicket.MarkupContainer
          extended by org.apache.wicket.markup.html.WebMarkupContainer
              extended by org.apache.wicket.markup.html.form.LabeledWebMarkupContainer
                  extended by org.apache.wicket.markup.html.form.FormComponent<T>
                      extended by org.apache.wicket.markup.html.form.FormComponentPanel<T>
Type Parameters:
T - The model object type
All Implemented Interfaces:, java.lang.Iterable<Component>, IEventSink, IEventSource, IClusterable, IConverterLocator, IFormModelUpdateListener, IFormVisitorParticipant, ILabelProvider<java.lang.String>, IHeaderContributor, IRequestableComponent, IHierarchical<Component>
Direct Known Subclasses:
DateTimeField, MultiFileUploadField, Multiply

public abstract class FormComponentPanel<T>
extends FormComponent<T>

Panel (has it's own markup, defined between tags), that can act as a form component. It typically wouldn't receive any input yourself, and often you can get by with nesting form components in panels proper. However, using this panel can help you with building components act to the outside world as one component, but internally uses separate components. This component would then use these nested components to handle it's internal state, and would use that internal state to get to one model object.

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 Component.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. For more complete examples of using this class, see the wicket-datetime project.

 public class Multiply extends FormComponentPanel
        private TextField left;
        private int lhs = 0;
        private int rhs = 0;
        private TextField right;
        public Multiply(String id)
        public Multiply(String id, IModel model)
                super(id, model);
        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));
With this markup:
     <input type="text" wicket:id="left" size="2" /> * <input type="text" wicket:id="right" size="2" />
Which could be used, for example as:
   add(new Multiply("multiply"), new PropertyModel(m, "multiply")));
   add(new Label("multiplyLabel", new PropertyModel(m, "multiply")));
   <span wicket:id="multiply">[multiply]</span>
   = <span wicket:id="multiplyLabel">[result]</span>

See Also:
Serialized Form

Field Summary
Fields inherited from class org.apache.wicket.markup.html.form.FormComponent
Fields inherited from class org.apache.wicket.Component
Constructor Summary
FormComponentPanel(java.lang.String id)
FormComponentPanel(java.lang.String id, IModel<T> model)
Method Summary
 boolean checkRequired()
          Checks if the form component's 'required' requirement is met by first checking FormComponent.isRequired() to see if it has to check for requirement.
protected  IMarkupSourcingStrategy newMarkupSourcingStrategy()
          If Component.getMarkupSourcingStrategy() returns null, this method will be called.
protected  void onComponentTag(ComponentTag tag)
          Processes the component tag.
Methods inherited from class org.apache.wicket.markup.html.form.FormComponent
add, add, clearInput, convertInput, convertValue, error, getConvertedInput, getDefaultLabel, getDefaultLabel, getForm, getInput, getInputAsArray, getInputName, getModel, getModelObject, getModelValue, getRawInput, getType, getValidatorKeyPrefix, getValidators, getValue, hasRawInput, inputAsInt, inputAsInt, inputAsIntArray, inputChanged, internalOnModelChanged, invalid, isInputNullable, isMultiPart, isRequired, isValid, newValidatable, onDetach, onDisabled, onInvalid, onValid, processChildren, processInput, remove, setConvertedInput, setLabel, setModel, setModelObject, setModelValue, setRequired, setType, shouldTrimInput, trim, updateCollectionModel, updateModel, valid, validate, validateRequired, validateValidators, visitComponentsPostOrder, visitFormComponentsPostOrder
Methods inherited from class org.apache.wicket.markup.html.form.LabeledWebMarkupContainer
getLabel, setLabelInternal
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebPage, getWebRequest
Methods inherited from class org.apache.wicket.MarkupContainer
add, addOrReplace, autoAdd, contains, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, hasAssociatedMarkup, internalAdd, internalInitialize, iterator, iterator, onAfterRenderChildren, onComponentTagBody, onMarkupAttached, onRender, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, swap, toString, toString, visitChildren, visitChildren, visitChildren, visitChildren
Methods inherited from class org.apache.wicket.Component
add, addStateChange, afterRender, beforeRender, canCallListenerInterface, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, 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, getFeedbackMessage, 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, internalPrepareForRender, internalRenderComponent, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, locateMarkupStream, markRendering, modelChanged, modelChanging, onAfterRender, onBeforeRender, onConfigure, onEvent, onInitialize, onModelChanged, onModelChanging, onRemove, prepareForRender, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderHead, 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, warn, wrap
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public FormComponentPanel(java.lang.String id)

id -


public FormComponentPanel(java.lang.String id,
                          IModel<T> model)

id -
model -
Method Detail


public boolean checkRequired()
Checks if the form component's 'required' requirement is met by first checking FormComponent.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 String Strings.isEmpty(CharSequence)

Subclasses that overwrite this method should also call FormComponent.isRequired() first.

checkRequired in class FormComponent<T>
true if the 'required' requirement is met, false otherwise
See Also:
Strings.isEmpty(CharSequence), FormComponent.isInputNullable()


protected IMarkupSourcingStrategy newMarkupSourcingStrategy()
If Component.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.

newMarkupSourcingStrategy in class Component
Markup sourcing strategy


protected void onComponentTag(ComponentTag tag)
Processes the component tag.

onComponentTag in class FormComponent<T>
tag - Tag to modify
See Also:

Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.