org.kuali.student.common.ui.client.configurable.mvc
Class FieldDescriptor

java.lang.Object
  extended by org.kuali.student.common.ui.client.configurable.mvc.FieldDescriptor
Direct Known Subclasses:
FieldDescriptorReadOnly

public class FieldDescriptor
extends Object

This is a field descriptor that defines ui fields. A field descriptor is defined by its fieldKey and its metadata, the field key is the key that is used to identify it during validation and save processing and maps directly to a field which exists in the model definition for the model it relates to. The fieldKey must match something within the model to be a valid field.
The metadata is its piece of information in the model definition which is used to generate the field's widget and determine what the validation on this field is (also if this field is backed by a search it will use the lookup metadata defined in its metadata to generate the appropriate search widget). It also determines if a requiredness indicator appears (constraint minOccurs > 1).

A field descriptor can be fully customized to any need, the widget can be chosen to be defined directly instead of using one that is auto generated by the metadata - if this is done make sure the data type it is using works with what is in the metadata and that it implements one of these standard interfaces:
HasText
KSSelectItemWidgetAbstract
HasDataValue
HasValue
or, you MUST override the ModelWidgetBinding by calling setModelWidgetBinding
Setting the ModelWidgetBinding allows you to manipulate the widget's data and model data as you see fit before a save when model data is loaded into the widget.

General layout of a field generated by FieldDescriptor, all elements are conditional based on the field's configuration:
[label][requiredness indicator][help]
[input widget]
[constraint text]

The messageKeyInfo passed in is used to generate the messages needed for a field these include:
Field Label
Help text
Instructions
Constraint text
Watermark text - only if the widget one that accepts text input

These are generated by a single key, the additional text is determined by special suffixes on keys within the messages data - example - you pass in "sampleField" for the message key - it is automatically determined that if there is a message in the message data named "sampleField-instruct", instructions will be added to the field in the appropriate location.
List of the appended keys for use in messages data:
"-help" for help text
"-instruct" for instructions
"-constraints" for constraint text
"-watermark" for watermark text

Author:
Kuali Student Team
See Also:
FieldElement, Section, BaseSection, Configurer

Field Summary
private  boolean dirty
           
private  FieldElement fieldElement
           
protected  String fieldKey
           
private  boolean hasHadFocus
           
private  MessageKeyInfo messageKey
           
protected  Metadata metadata
           
private  String modelId
           
private  ModelWidgetBinding modelWidgetBinding
           
private  boolean optional
           
private  Callback<Boolean> validationRequestCallback
           
 
Constructor Summary
FieldDescriptor(String fieldKey, MessageKeyInfo messageKey, Metadata metadata)
           
FieldDescriptor(String fieldKey, MessageKeyInfo messageKey, Metadata metadata, com.google.gwt.user.client.ui.Widget fieldWidget)
           
 
Method Summary
protected  void addStyleToWidget(com.google.gwt.user.client.ui.Widget w)
           
protected  com.google.gwt.user.client.ui.Widget createFieldWidget()
           
 FieldElement getFieldElement()
           
 String getFieldKey()
           
 String getFieldLabel()
           
 com.google.gwt.user.client.ui.Widget getFieldWidget()
           
 MessageKeyInfo getMessageKey()
           
 Metadata getMetadata()
           
 String getModelId()
           
 ModelWidgetBinding<?> getModelWidgetBinding()
           
 Callback<Boolean> getValidationRequestCallback()
           
 boolean hasHadFocus()
          Return true if the field has been touched by the user in some fashion, this is set by the field's section
 void hideLabel()
           
 boolean isDirty()
          Returns true if this field is marked as dirty.
 boolean isLabelShown()
           
 boolean isOptional()
          Fields that are optional should not be displayed if there is no data in some cases, it is up to the section implementation whether or not to honor this flag
 boolean isVisible()
           
 void setDirty(boolean dirty)
           
 void setFieldKey(String fieldKey)
           
 void setFieldWidget(com.google.gwt.user.client.ui.Widget fieldWidget)
           
 void setHasHadFocus(boolean hasHadFocus)
           
 void setMessageKey(MessageKeyInfo messageKey)
           
 void setMetadata(Metadata metadata)
           
 void setModelId(String modelId)
           
 void setOptional(boolean optional)
          Sets the optional flag Fields that are optional should not be displayed if there is no data in some cases, it is up to the section implementation whether or not to honor this flag
protected  void setupField()
           
 void setValidationCallBack(Callback<Boolean> callback)
          Allows additional processing to happen when a validation check is being processed when the input widget loses focus defined in the callback
 void setWidgetBinding(ModelWidgetBinding widgetBinding)
          Sets the ModelWidgetBinding for this field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fieldKey

protected String fieldKey

metadata

protected Metadata metadata

modelWidgetBinding

private ModelWidgetBinding modelWidgetBinding

validationRequestCallback

private Callback<Boolean> validationRequestCallback

dirty

private boolean dirty

hasHadFocus

private boolean hasHadFocus

fieldElement

private final FieldElement fieldElement

modelId

private String modelId

messageKey

private MessageKeyInfo messageKey

optional

private boolean optional
Constructor Detail

FieldDescriptor

public FieldDescriptor(String fieldKey,
                       MessageKeyInfo messageKey,
                       Metadata metadata)
Parameters:
fieldKey - - key for this field which matches a field in the overall model definition that this field will be used for
messageKey - - key object used for determing field labels
metadata - - metadata used to determine requiredness, validation, and autogenerated widget

FieldDescriptor

public FieldDescriptor(String fieldKey,
                       MessageKeyInfo messageKey,
                       Metadata metadata,
                       com.google.gwt.user.client.ui.Widget fieldWidget)
Parameters:
fieldKey - - key for this field which matches a field in the overall model definition that this field will be used for
messageKey - - key object used for determing field labels
metadata - - metadata used to determine requiredness and validation
fieldWidget - - widget to use instead of an automatically determined one
Method Detail

addStyleToWidget

protected void addStyleToWidget(com.google.gwt.user.client.ui.Widget w)

setupField

protected void setupField()

hideLabel

public void hideLabel()
See Also:
FieldElement.hideLabel()

isLabelShown

public boolean isLabelShown()

getFieldElement

public FieldElement getFieldElement()

getFieldKey

public String getFieldKey()

setFieldKey

public void setFieldKey(String fieldKey)

getFieldLabel

public String getFieldLabel()

getFieldWidget

public com.google.gwt.user.client.ui.Widget getFieldWidget()

createFieldWidget

protected com.google.gwt.user.client.ui.Widget createFieldWidget()

getModelWidgetBinding

public ModelWidgetBinding<?> getModelWidgetBinding()

setValidationCallBack

public void setValidationCallBack(Callback<Boolean> callback)
Allows additional processing to happen when a validation check is being processed when the input widget loses focus defined in the callback

Parameters:
callback -

getValidationRequestCallback

public Callback<Boolean> getValidationRequestCallback()

isDirty

public boolean isDirty()
Returns true if this field is marked as dirty. In KS, dirty is when the field has been changed in some way - however not completely accurate

Returns:

setDirty

public void setDirty(boolean dirty)

hasHadFocus

public boolean hasHadFocus()
Return true if the field has been touched by the user in some fashion, this is set by the field's section

Returns:

setHasHadFocus

public void setHasHadFocus(boolean hasHadFocus)

getMetadata

public Metadata getMetadata()

setMetadata

public void setMetadata(Metadata metadata)

setFieldWidget

public void setFieldWidget(com.google.gwt.user.client.ui.Widget fieldWidget)

getModelId

public String getModelId()

setModelId

public void setModelId(String modelId)

setWidgetBinding

public void setWidgetBinding(ModelWidgetBinding widgetBinding)
Sets the ModelWidgetBinding for this field. Changing this changes the way data from the server and passed to the server is processed with the widget. Set this when some special processing or handling has to happen with the data in either phase.

Parameters:
widgetBinding -

getMessageKey

public MessageKeyInfo getMessageKey()

setMessageKey

public void setMessageKey(MessageKeyInfo messageKey)

setOptional

public void setOptional(boolean optional)
Sets the optional flag Fields that are optional should not be displayed if there is no data in some cases, it is up to the section implementation whether or not to honor this flag

Parameters:
optional -

isOptional

public boolean isOptional()
Fields that are optional should not be displayed if there is no data in some cases, it is up to the section implementation whether or not to honor this flag


isVisible

public boolean isVisible()
Returns:
true if this field is visible to the user


Copyright © 2007-2011 The Kuali Foundation. All Rights Reserved.