net.databinder.components.hib
Class DataForm

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.form.Form
                  extended by net.databinder.components.hib.DataFormBase
                      extended by net.databinder.components.hib.DataForm
All Implemented Interfaces:
java.io.Serializable, org.apache.wicket.IClusterable, org.apache.wicket.IConverterLocator, org.apache.wicket.IRequestListener, org.apache.wicket.markup.html.form.IFormSubmitListener
Direct Known Subclasses:
ValidDataForm

public class DataForm
extends DataFormBase

Form for a persistent model object nested in a BoundCompoundPropertyModel. Saves the model object to persistent storage when a valid form is submitted. This form can be a child component of any Wicket page.

Author:
Nathan Hamblen
See Also:
Serialized Form

Nested Class Summary
 class DataForm.ClearLink
           
 
Nested classes/interfaces inherited from class org.apache.wicket.markup.html.form.Form
org.apache.wicket.markup.html.form.Form.ValidationVisitor
 
Nested classes/interfaces inherited from class org.apache.wicket.Component
org.apache.wicket.Component.ComponentModelChange, org.apache.wicket.Component.EnabledChange, org.apache.wicket.Component.IVisitor, org.apache.wicket.Component.VisibilityChange
 
Field Summary
 
Fields inherited from class org.apache.wicket.markup.html.form.Form
METHOD_GET, METHOD_POST
 
Fields inherited from class org.apache.wicket.Component
ENABLE, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PATH_SEPARATOR, RENDER
 
Fields inherited from interface org.apache.wicket.markup.html.form.IFormSubmitListener
INTERFACE
 
Constructor Summary
DataForm(java.lang.String id)
          Form that is nested below a component with a compound model containing a Hibernate model.
DataForm(java.lang.String id, java.lang.Class modelClass)
          Instantiates this form and a new, blank instance of the given class as a persistent model object.
DataForm(java.lang.String id, java.lang.Class modelClass, java.io.Serializable persistentObjectId)
          Instantiates this form with a persistent object of the given class and id.
DataForm(java.lang.String id, HibernateObjectModel model)
           
 
Method Summary
 DataForm clearPersistentObject()
          Replaces the form's model object with a new, blank instance.
protected  boolean deletePersistentObject()
          Deletes the form's model object from persistent storage.
protected  org.apache.wicket.model.CompoundPropertyModel getCompoundModel()
           
 HibernateObjectModel getPersistentObjectModel()
           
protected  java.io.Serializable getVersion()
           
protected  void onBeforeRender()
          Late-init version record.
protected  void onModelChanged()
           
protected  void onSubmit()
          Saves the form's model object to persistent storage if it is new and commits the database transaction.
 DataForm setFactoryKey(java.lang.Object key)
           
 DataForm setPersistentObject(java.lang.Object object)
          Change the persistent model object of this form.
protected  void validate()
          Checks that the version number, if present, is the last known version number.
 
Methods inherited from class net.databinder.components.hib.DataFormBase
getFactoryKey, getHibernateSession
 
Methods inherited from class org.apache.wicket.markup.html.form.Form
add, appendDefaultButtonField, beforeUpdateFormComponentModels, clearInput, delegateSubmit, error, findSubmittingButton, getDefaultButton, getFormValidators, getHiddenFieldId, getInputNamePrefix, getJavascriptId, getJsForInterfaceUrl, getMaxSize, getMethod, getRootForm, getStatelessHint, getValidatorKeyPrefix, getValuePersister, handleMultiPart, hasError, internalOnModelChanged, isRootForm, isSubmitted, isVersioned, loadPersistentFormComponentValues, markFormComponentsInvalid, markFormComponentsValid, onComponentTag, onComponentTagBody, onDetach, onError, onFormSubmitted, onRender, process, remove, removePersistentFormComponentValues, setDefaultButton, setMaxSize, setMultiPart, setVersioned, updateFormComponentModels, validateComponents, validateFormValidator, validateFormValidators, visitFormComponents, visitFormComponentsPostOrder, writeParamsAsHiddenFields
 
Methods inherited from class org.apache.wicket.markup.html.WebMarkupContainer
getMarkupType, getWebPage
 
Methods inherited from class org.apache.wicket.MarkupContainer
add, addOrReplace, autoAdd, autoAdd, contains, findMarkupStream, get, getAssociatedMarkupStream, getMarkupStream, hasAssociatedMarkup, internalAdd, isTransparentResolver, iterator, iterator, newMarkupResourceStream, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderComponentTagBody, replace, setMarkupStream, setModel, size, toString, toString, visitChildren, visitChildren
 
Methods inherited from class org.apache.wicket.Component
add, addStateChange, afterRender, beforeRender, callOnBeforeRenderIfNotVisible, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, continueToOriginalDestination, debug, detach, detachBehaviors, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findPage, findParent, findParentWithAssociatedMarkup, getApplication, getBehaviors, getBehaviors, getClassRelativePath, getComponentBorder, getConverter, getConverter, getEscapeModelStrings, getFeedbackMessage, getFlag, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkupAttributes, getMarkupId, getMarkupId, getMetaData, getModel, getModelComparator, getModelObject, getModelObjectAsString, getModelObjectAsString, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageFactory, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResponse, getSession, getSizeInBytes, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalAttach, internalDetach, internalOnAttach, internalOnDetach, isActionAuthorized, isAncestorOf, isAttached, isBehaviorAccepted, isEnableAllowed, isEnabled, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVisibilityAllowed, isVisible, isVisibleInHierarchy, locateMarkupStream, markAttached, markRendering, modelChanged, modelChanging, newPage, newPage, onAfterRender, onAttach, onBeginRequest, onEndRequest, onModelChanging, prepareForRender, redirectToInterceptPage, remove, remove, render, render, renderComponent, renderComponent, renderComponentTag, rendered, renderHead, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, setAuto, setComponentBorder, setEnabled, setEscapeModelStrings, setFlag, setFlag, setIgnoreAttributeModifier, setMarkupId, setMetaData, setModelObject, setOutputMarkupId, setOutputMarkupPlaceholderTag, setRedirect, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVisibilityAllowed, setVisible, urlFor, 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

DataForm

public DataForm(java.lang.String id,
                java.lang.Class modelClass)
Instantiates this form and a new, blank instance of the given class as a persistent model object. By default the model object created is serialized and retained between requests until it is persisted.

Parameters:
id -
modelClass - for the persistent object
See Also:
HibernateObjectModel.setRetainUnsaved(boolean)

DataForm

public DataForm(java.lang.String id,
                HibernateObjectModel model)

DataForm

public DataForm(java.lang.String id,
                java.lang.Class modelClass,
                java.io.Serializable persistentObjectId)
Instantiates this form with a persistent object of the given class and id.

Parameters:
id - Wicket id
modelClass - for the persistent object
persistentObjectId - id of the persistent object

DataForm

public DataForm(java.lang.String id)
Form that is nested below a component with a compound model containing a Hibernate model.

Parameters:
id -
Method Detail

setFactoryKey

public DataForm setFactoryKey(java.lang.Object key)
Overrides:
setFactoryKey in class DataFormBase
Parameters:
key - for the Hibernate session factory to be used with this component
Returns:
this

getPersistentObjectModel

public HibernateObjectModel getPersistentObjectModel()

setPersistentObject

public DataForm setPersistentObject(java.lang.Object object)
Change the persistent model object of this form.

Parameters:
object - to attach to this form
Returns:
this form, for chaining

onBeforeRender

protected void onBeforeRender()
Late-init version record.

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

onModelChanged

protected void onModelChanged()
Overrides:
onModelChanged in class org.apache.wicket.Component

clearPersistentObject

public DataForm clearPersistentObject()
Replaces the form's model object with a new, blank instance. Does not affect persistent storage.

Returns:
this form, for chaining

getCompoundModel

protected org.apache.wicket.model.CompoundPropertyModel getCompoundModel()

onSubmit

protected void onSubmit()
Saves the form's model object to persistent storage if it is new and commits the database transaction.

Overrides:
onSubmit in class DataFormBase

validate

protected void validate()
Checks that the version number, if present, is the last known version number. If it does not match, validation fails and will continue to fail until the form is reloaded with the updated data and version number. This allows the user to preserve her unsaved changes while preventing overwrites.

Note: although timestamp versions are supported, beware of rounding errors. equals() must return true when comparing the retained version object to the one loaded from persistent storage.

Overrides:
validate in class org.apache.wicket.markup.html.form.Form

getVersion

protected java.io.Serializable getVersion()
Returns:
persistent storage version number if available, null otherwise

deletePersistentObject

protected boolean deletePersistentObject()
Deletes the form's model object from persistent storage. Flushes change so that queries executed in the same request (e.g., in a HibernateListModel) will not return this object.

Returns:
true if the object was deleted, false if it did not exist


Copyright © 2005-2008 Nathan Hamblen. All Rights Reserved.