org.ujorm.wicket.component.form.fields
Class Field<T>

java.lang.Object
  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.panel.Panel
                  extended by org.apache.wicket.markup.html.panel.GenericPanel<T>
                      extended by org.ujorm.wicket.component.form.fields.Field<T>
Type Parameters:
T - Field value type
All Implemented Interfaces:
Serializable, Iterable<org.apache.wicket.Component>, org.apache.wicket.event.IEventSink, org.apache.wicket.event.IEventSource, org.apache.wicket.IConverterLocator, org.apache.wicket.IGenericComponent<T>, org.apache.wicket.markup.html.IHeaderContributor, org.apache.wicket.request.component.IRequestableComponent, org.apache.wicket.util.IHierarchical<org.apache.wicket.Component>, org.apache.wicket.util.io.IClusterable
Direct Known Subclasses:
BooleanField, ComboField, DateField, EnumField, FeedbackField, GridField, PasswordField, TextAreaField, TextField

public class Field<T>
extends org.apache.wicket.markup.html.panel.GenericPanel<T>

Common Input field with a Label including a feedback message.

Author:
Pavel Ponec
See Also:
Serialized Form

Field Summary
protected  List<org.apache.wicket.behavior.Behavior> behaviors
           
static String CSS_REQUIRED
          CSS required style for the Label
protected  String cssClass
           
protected static org.apache.wicket.util.time.Duration DEFAULT_DELAY
          Delay for searching fields is 400 [ms] by default
protected  FeedbackLabel feedback
           
protected  KeyRing<?> key
          Serializable key
static String PROPERTY_PREFIX
          Localization key prefix
protected  List<org.apache.wicket.validation.IValidator<? super T>> validators
           
 
Fields inherited from class org.apache.wicket.markup.html.panel.Panel
PANEL
 
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_INITIALIZED, FLAG_REMOVING_FROM_HIERARCHY, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER
 
Constructor Summary
Field(Key<U,T> key)
           
Field(String componentId, Key<U,T> key, String cssClass)
          The default constructor
 
Method Summary
 void addBehaviour(org.apache.wicket.ajax.AjaxEventBehavior behavior)
          add Behaviour
 org.apache.wicket.ajax.AjaxEventBehavior addBehaviourOnBlur()
          Add a new AjaxFormComponentUpdatingBehavior|Behavior to updating a component model on blur events.
protected  void addMaxLength(org.apache.wicket.markup.html.form.FormComponent result)
          Add a maxlength of a text-field for String attributes
 Field addValidator(org.apache.wicket.validation.IValidator<T> validator)
          Validator setter
 Field addValidator(Validator<T> validator)
          The Validator setter
protected  org.apache.wicket.ajax.AjaxEventBehavior createChangeBehaviour(String action, String jsEvent)
          Create new AjaxFormComponentUpdatingBehavior with delay 300 ms.
protected  org.apache.wicket.markup.html.form.FormComponent createInput(String componentId, org.apache.wicket.model.IModel<T> model)
          Create Form inputComponent
protected  org.apache.wicket.Component createLabel(org.apache.wicket.Component inp)
          Create Label and assign the CSS class required for the mandatory Field
protected  org.apache.wicket.model.IModel createLabelModel()
          Create label model
protected  String getCssClass()
          Returns a main CSS class
 org.apache.wicket.markup.html.form.FormComponent getInput()
          Return an Input component
 Key<?,?> getKey()
          Returns assigned key
 T getModelValue()
          Returns an input value from model
protected  String getResourceLabelKey(Key<?,?> key)
          Resource Label Key
 List<org.apache.wicket.validation.IValidator<? super T>> getValidators()
          Validator getter
 org.apache.wicket.model.IModel<Boolean> getVisibleModel()
          Extended visible model, the null value means a default manner.
protected  boolean isRequired()
          Is the field required ?
 void onChange(String action)
          Create an Updating Behavior with "keyup" event
protected  void onConfigure()
          On configure
protected  void onInitialize()
          On initialize
protected  void onSuperInitialize()
          Initialize a super class for special cases
 void requestFocus(org.apache.wicket.ajax.AjaxRequestTarget target)
          Set a focus to the component
 void setFeedbackMessage(org.apache.wicket.model.IModel<String> message)
          Assign a feedback message
 void setModelValue(T value)
          Set new value for the input and reset feedback messages
 void setVisibleModel(org.apache.wicket.model.IModel<Boolean> visibleModel)
          Extended visible model, the null value means a default manner.
 String toString()
          A debug information
 
Methods inherited from class org.apache.wicket.markup.html.panel.GenericPanel
getModel, getModelObject, setModel, setModelObject
 
Methods inherited from class org.apache.wicket.markup.html.panel.Panel
newMarkupSourcingStrategy
 
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getWebPage, getWebRequest, getWebResponse, getWebSession
 
Methods inherited from class org.apache.wicket.MarkupContainer
add, addOrReplace, autoAdd, contains, get, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, internalAdd, internalInitialize, iterator, iterator, onAfterRenderChildren, onComponentTagBody, onRender, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, swap, toString, visitChildren, visitChildren, visitChildren, visitChildren
 
Methods inherited from class org.apache.wicket.Component
add, addStateChange, afterRender, beforeRender, canCallListenerInterface, 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, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, onAfterRender, onBeforeRender, onComponentTag, onDetach, onEvent, 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, visitParents, warn, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_DELAY

protected static final org.apache.wicket.util.time.Duration DEFAULT_DELAY
Delay for searching fields is 400 [ms] by default


CSS_REQUIRED

public static final String CSS_REQUIRED
CSS required style for the Label

See Also:
Constant Field Values

PROPERTY_PREFIX

public static final String PROPERTY_PREFIX
Localization key prefix

See Also:
Constant Field Values

feedback

protected FeedbackLabel feedback

validators

protected List<org.apache.wicket.validation.IValidator<? super T>> validators

cssClass

protected String cssClass

key

protected KeyRing<?> key
Serializable key


behaviors

protected List<org.apache.wicket.behavior.Behavior> behaviors
Constructor Detail

Field

public Field(Key<U,T> key)

Field

public Field(String componentId,
             Key<U,T> key,
             String cssClass)
The default constructor

Parameters:
componentId - Required component
key - Optional Ujorm Key
cssClass - Optional CSS class
Method Detail

onSuperInitialize

protected final void onSuperInitialize()
Initialize a super class for special cases


onInitialize

protected void onInitialize()
On initialize

Overrides:
onInitialize in class org.apache.wicket.Component

onConfigure

protected void onConfigure()
On configure

Overrides:
onConfigure in class org.apache.wicket.Component

createInput

protected org.apache.wicket.markup.html.form.FormComponent createInput(String componentId,
                                                                       org.apache.wicket.model.IModel<T> model)
Create Form inputComponent


getValidators

@Nonnull
public List<org.apache.wicket.validation.IValidator<? super T>> getValidators()
Validator getter


addValidator

public Field addValidator(org.apache.wicket.validation.IValidator<T> validator)
Validator setter


addValidator

public Field addValidator(Validator<T> validator)
The Validator setter


getModelValue

public T getModelValue()
Returns an input value from model


setModelValue

public void setModelValue(T value)
Set new value for the input and reset feedback messages


addBehaviour

public void addBehaviour(org.apache.wicket.ajax.AjaxEventBehavior behavior)
add Behaviour


getInput

public org.apache.wicket.markup.html.form.FormComponent getInput()
Return an Input component


addMaxLength

protected void addMaxLength(org.apache.wicket.markup.html.form.FormComponent result)
Add a maxlength of a text-field for String attributes


createLabel

protected org.apache.wicket.Component createLabel(org.apache.wicket.Component inp)
Create Label and assign the CSS class required for the mandatory Field


createLabelModel

protected org.apache.wicket.model.IModel createLabelModel()
Create label model


getResourceLabelKey

protected String getResourceLabelKey(Key<?,?> key)
Resource Label Key


isRequired

protected boolean isRequired()
Is the field required ?


getKey

@Nullable
public Key<?,?> getKey()
Returns assigned key


setFeedbackMessage

public void setFeedbackMessage(org.apache.wicket.model.IModel<String> message)
Assign a feedback message


getCssClass

protected String getCssClass()
Returns a main CSS class


getVisibleModel

public org.apache.wicket.model.IModel<Boolean> getVisibleModel()
Extended visible model, the null value means a default manner.


setVisibleModel

public void setVisibleModel(org.apache.wicket.model.IModel<Boolean> visibleModel)
Extended visible model, the null value means a default manner.


onChange

public void onChange(String action)
Create an Updating Behavior with "keyup" event

Parameters:
field - Field is not used by default, however it can be a switch for different results for example.

createChangeBehaviour

protected org.apache.wicket.ajax.AjaxEventBehavior createChangeBehaviour(String action,
                                                                         String jsEvent)
Create new AjaxFormComponentUpdatingBehavior with delay 300 ms.


addBehaviourOnBlur

public org.apache.wicket.ajax.AjaxEventBehavior addBehaviourOnBlur()
Add a new AjaxFormComponentUpdatingBehavior|Behavior to updating a component model on blur events.


requestFocus

public void requestFocus(@Nonnull
                         org.apache.wicket.ajax.AjaxRequestTarget target)
Set a focus to the component


toString

public String toString()
A debug information

Overrides:
toString in class org.apache.wicket.MarkupContainer


Copyright © 2014. All Rights Reserved.