|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.wicket.Component
org.apache.wicket.MarkupContainer
org.apache.wicket.markup.html.WebMarkupContainer
org.apache.wicket.markup.html.form.LabeledWebMarkupContainer
org.apache.wicket.markup.html.form.FormComponent<T>
org.apache.wicket.markup.html.form.FormComponentPanel<T>
T
- The model object typepublic abstract class FormComponentPanel<T>
Panel (has it's own markup, defined between
It is recommended that you override
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.
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.
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>
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.apache.wicket.markup.html.form.FormComponent |
---|
FormComponent.AbstractVisitor, FormComponent.IVisitor |
Nested classes/interfaces inherited from class org.apache.wicket.Component |
---|
Component.ComponentModelChange, Component.EnabledChange, Component.VisibilityChange |
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_CONFIGURED, FLAG_INITIALIZED, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER |
Constructor Summary | |
---|---|
FormComponentPanel(String id)
Construct. |
|
FormComponentPanel(String id,
IModel<T> model)
Construct. |
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. |
HeaderPartContainer |
newHeaderPartContainer(String id,
String scope)
Create a new HeaderPartContainer. |
protected void |
onComponentTag(ComponentTag tag)
Processes the component tag. |
protected void |
onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag)
Handle the container's body. |
void |
renderHead(HtmlHeaderContainer container)
Check the associated markup file for a wicket header 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, isPersistent, isRequired, isValid, newValidatable, onDetach, onDisabled, onInvalid, onValid, processChildren, processInput, setConvertedInput, setLabel, setModel, setModelObject, setModelValue, setModelValue, setPersistent, setRequired, setType, shouldTrimInput, supportsPersistence, trim, 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 |
---|
getMarkupType, getWebPage, getWebRequest |
Methods inherited from class org.apache.wicket.MarkupContainer |
---|
add, addOrReplace, autoAdd, autoAdd, contains, findMarkupStream, get, get, getAssociatedMarkupStream, getMarkupStream, hasAssociatedMarkup, internalAdd, isTransparentResolver, iterator, iterator, newMarkupResourceStream, onAfterRenderChildren, onRender, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderComponentTagBody, renderNext, replace, setDefaultModel, setMarkupStream, size, swap, toString, toString, visitChildren, visitChildren |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FormComponentPanel(String id)
id
- public FormComponentPanel(String id, IModel<T> model)
id
- model
- Method Detail |
---|
public boolean checkRequired()
FormComponent
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>
FormComponent.checkRequired()
public HeaderPartContainer newHeaderPartContainer(String id, String scope)
IHeaderPartContainerProvider
newHeaderPartContainer
in interface IHeaderPartContainerProvider
id
- The header component's idscope
- The default scope of the header
IHeaderPartContainerProvider.newHeaderPartContainer(java.lang.String,
java.lang.String)
public void renderHead(HtmlHeaderContainer container)
renderHead
in class Component
container
- The HtmlHeaderContainerComponent.renderHead(org.apache.wicket.markup.html.internal.HtmlHeaderContainer)
protected void onComponentTag(ComponentTag tag)
FormComponent
onComponentTag
in class FormComponent<T>
tag
- Tag to modifyComponent.onComponentTag(org.apache.wicket.markup.ComponentTag)
protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag)
MarkupContainer
onComponentTagBody
in class MarkupContainer
markupStream
- The markup streamopenTag
- The open tag for the bodyComponent.onComponentTagBody(org.apache.wicket.markup.MarkupStream,
org.apache.wicket.markup.ComponentTag)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |