com.sun.webui.jsf.component
Class TextField

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by javax.faces.component.UIComponentBase
          extended by javax.faces.component.UIOutput
              extended by javax.faces.component.UIInput
                  extended by com.sun.webui.jsf.component.WebuiInput
                      extended by com.sun.webui.jsf.component.HiddenField
                          extended by com.sun.webui.jsf.component.Field
                              extended by com.sun.webui.jsf.component.TextField
All Implemented Interfaces:
com.sun.webui.jsf.component.ComplexComponent, javax.faces.component.EditableValueHolder, javax.faces.component.NamingContainer, javax.faces.component.StateHolder, javax.faces.component.ValueHolder
Direct Known Subclasses:
Calendar, EditableField, TextArea

public class TextField
extends Field

The TextField component renders input HTML element.
TextField Component class represents text input element.
As part of the dynamic behavior, TextField supports auto-validation, where entered data is automatically validated through the ajax call to the server. When validating data through the ajax-based mechanism, the UPDATE_MODEL_VALUES stage of the lifecycle is skipped ( see processUpdates).

Another dynamic feature of TextField is an autoComplete. If autoComplete attribute is specified as true, this list will be rendered under the text input to allow user to pick a selection from the list instead of ( or in addition to ) typing it. Once autoComplete is activated, every time the content of the TextField is changed, the updated text field value is used to fetch autocomplete list with Ajax call. Developer must provide bean method ( see attribute autoCompleteExpression) to filter and retrieve options on every Ajax call. Such bean must implement AutoComplete interface.

Thus the following pattern is followed for autoComplete:


Field Summary
 
Fields inherited from class com.sun.webui.jsf.component.Field
INPUT_ID, LABEL_FACET, LABEL_ID, READONLY_FACET, READONLY_ID
 
Fields inherited from class javax.faces.component.UIInput
COMPONENT_FAMILY, COMPONENT_TYPE, CONVERSION_MESSAGE_ID, REQUIRED_MESSAGE_ID, UPDATE_MESSAGE_ID
 
Fields inherited from interface javax.faces.component.NamingContainer
SEPARATOR_CHAR
 
Constructor Summary
TextField()
          Construct a new TextField.
 
Method Summary
 javax.el.MethodExpression getAutoCompleteExpression()
          Returns the stored autoCompleteExpression.
 java.lang.String getFamily()
          Return the family for this component.
 java.lang.String getNotify()
          Get the comma separated list of absolute client IDs to notify during text field events.
 java.lang.String getRendererType()
          Returns the renderer type for the component.
 java.lang.String getValueAsString(javax.faces.context.FacesContext context)
          Return the value to be rendered, as a String (converted if necessary), or null if the value is null.
 boolean isAutoComplete()
          Test if default Ajax functionality should be turned off.
 boolean isAutoValidate()
          Test if default Ajax functionality should be turned off.
 boolean isSubmitForm()
          Flag indicating whether pressing enter in this text field would allow browser to submit the enclosing form.
 boolean isSubmitFormSet()
          Returns true if submitForm attribute has been explicitely set, either through binding, value expression, or programmatically.
 void processUpdates(javax.faces.context.FacesContext context)
          Specialized model update behavior on top of that provided by the superclass.
 void restoreState(javax.faces.context.FacesContext _context, java.lang.Object _state)
          Restore the state of this component.
 java.lang.Object saveState(javax.faces.context.FacesContext _context)
          Save the state of this component.
 void setAutoComplete(boolean autoComplete)
          Set attribute indicating to turn on/off default Ajax functionality.
 void setAutoCompleteExpression(javax.el.MethodExpression me)
          Stores the autoCompleteExpression.
 void setAutoValidate(boolean autoValidate)
          Set attribute indicating to turn on/off default Ajax functionality.
 void setNotify(java.lang.String notify)
          Set the comma separated list of absolute client IDs to notify during text field events.
 void setSubmitForm(boolean submitForm)
          Flag indicating whether pressing enter in this text field would allow browser to submit the enclosing form.
 
Methods inherited from class com.sun.webui.jsf.component.Field
getColumns, getFocusElementId, getIndicatorComponent, getLabel, getLabelComponent, getLabeledElementId, getLabelLevel, getMaxLength, getOnBlur, getOnChange, getOnClick, getOnDblClick, getOnFocus, getOnKeyDown, getOnKeyPress, getOnKeyUp, getOnMouseDown, getOnMouseMove, getOnMouseOut, getOnMouseOver, getOnMouseUp, getOnSelect, getPrimaryElementID, getReadOnlyComponent, getStyle, getStyleClass, getTabIndex, getText, getToolTip, getValue, getValueExpression, isDisabled, isReadOnly, isRequired, isTrim, isVisible, setColumns, setDisabled, setLabel, setLabelLevel, setMaxLength, setOnBlur, setOnChange, setOnClick, setOnDblClick, setOnFocus, setOnKeyDown, setOnKeyPress, setOnKeyUp, setOnMouseDown, setOnMouseMove, setOnMouseOut, setOnMouseOver, setOnMouseUp, setOnSelect, setReadOnly, setStyle, setStyleClass, setTabIndex, setText, setToolTip, setTrim, setValueExpression, setVisible
 
Methods inherited from class com.sun.webui.jsf.component.HiddenField
getHtmlTemplate, getReadOnlyValueString, setHtmlTemplate
 
Methods inherited from class com.sun.webui.jsf.component.WebuiInput
broadcast, getValidator, getValidatorExpression, getValueChangeListener, getValueChangeListenerExpression, processDecodes, processValidators, setConverter, setId, setImmediate, setRendered, setRequired, setValidatorExpression, setValueChangeListenerExpression
 
Methods inherited from class javax.faces.component.UIInput
addValidator, addValueChangeListener, decode, getConverterMessage, getRequiredMessage, getSubmittedValue, getValidatorMessage, getValidators, getValueChangeListeners, isImmediate, isLocalValueSet, isValid, removeValidator, removeValueChangeListener, resetValue, setConverterMessage, setLocalValueSet, setRequiredMessage, setSubmittedValue, setValid, setValidator, setValidatorMessage, setValue, setValueChangeListener, updateModel, validate
 
Methods inherited from class javax.faces.component.UIOutput
getConverter, getLocalValue
 
Methods inherited from class javax.faces.component.UIComponentBase
encodeBegin, encodeChildren, encodeEnd, findComponent, getAttributes, getChildCount, getChildren, getClientId, getFacet, getFacetCount, getFacets, getFacetsAndChildren, getId, getParent, getRendersChildren, getValueBinding, invokeOnComponent, isRendered, isTransient, processRestoreState, processSaveState, queueEvent, restoreAttachedState, saveAttachedState, setParent, setRendererType, setTransient, setValueBinding
 
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getContainerClientId
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.faces.component.ValueHolder
getConverter, getLocalValue
 

Constructor Detail

TextField

public TextField()

Construct a new TextField.

Method Detail

getFamily

public java.lang.String getFamily()

Return the family for this component.

Overrides:
getFamily in class Field

getRendererType

public java.lang.String getRendererType()
Returns the renderer type for the component. Depending on the type of the request, this method will return the default renderer type of "com.sun.webui.jsf.widget.TextField" in case of regular render request, or "com.sun.webui.jsf.ajax.TextField" in case of ajax request. Ajax request represents a special case of request, when partial data is rendered back to the client.

Overrides:
getRendererType in class HiddenField

getValueAsString

public java.lang.String getValueAsString(javax.faces.context.FacesContext context)

Return the value to be rendered, as a String (converted if necessary), or null if the value is null.

Overrides:
getValueAsString in class HiddenField
Parameters:
context - FacesContext for the current request
Returns:
A String value of the component

getAutoCompleteExpression

public javax.el.MethodExpression getAutoCompleteExpression()

Returns the stored autoCompleteExpression.


setAutoCompleteExpression

public void setAutoCompleteExpression(javax.el.MethodExpression me)

Stores the autoCompleteExpression.


isAutoComplete

public boolean isAutoComplete()
Test if default Ajax functionality should be turned off.


setAutoComplete

public void setAutoComplete(boolean autoComplete)
Set attribute indicating to turn on/off default Ajax functionality. When on, autocomplete options will be displayed as user types in data.
AutoComplete requires autoCompleteExpression to be set.
                    < webuijsf:textField
                        id="textFieldA"
                        size="20"
                        required="true"
                        autoComplete="true"
                        autoCompleteExpression="#{MyBean.autoCompleteExpression}"
                    / >
 


isAutoValidate

public boolean isAutoValidate()
Test if default Ajax functionality should be turned off.


setAutoValidate

public void setAutoValidate(boolean autoValidate)
Set attribute indicating to turn on/off default Ajax functionality. When on, TextField's onBlur event will generate ajax-based validation request, where content of the TextField's input will be validated ( but not committed during the processUpdates stage). Validation information is sent back to the browser for user information in form of success or standard FacesMesssages in case of failure.
AutoValidate requires validator to be set ( via validatorExpression)
                    < webuijsf:textField
                        id="textFieldA"
                        text="4111 1111 1111 1111"
                        label="Enter Credit Card Number"
                        size="20"
                        required="true"
                        autoValidate="true"
                        validatorExpression="#{Payment.cardValidator}"
                    / >
 


getNotify

public java.lang.String getNotify()
Get the comma separated list of absolute client IDs to notify during text field events.


setNotify

public void setNotify(java.lang.String notify)
Set the comma separated list of absolute client IDs to notify during text field events.


isSubmitForm

public boolean isSubmitForm()

Flag indicating whether pressing enter in this text field would allow browser to submit the enclosing form.


setSubmitForm

public void setSubmitForm(boolean submitForm)

Flag indicating whether pressing enter in this text field would allow browser to submit the enclosing form.

See Also:
isSubmitForm()

isSubmitFormSet

public boolean isSubmitFormSet()

Returns true if submitForm attribute has been explicitely set, either through binding, value expression, or programmatically. Returns false otherwise.


processUpdates

public void processUpdates(javax.faces.context.FacesContext context)

Specialized model update behavior on top of that provided by the superclass.

Overrides:
processUpdates in class WebuiInput
Parameters:
context - FacesContext for this request.

restoreState

public void restoreState(javax.faces.context.FacesContext _context,
                         java.lang.Object _state)
Restore the state of this component.

Specified by:
restoreState in interface javax.faces.component.StateHolder
Overrides:
restoreState in class Field

saveState

public java.lang.Object saveState(javax.faces.context.FacesContext _context)
Save the state of this component.

Specified by:
saveState in interface javax.faces.component.StateHolder
Overrides:
saveState in class Field


Copyright © 2008 Sun Microsystems, Inc. All Rights Reserved.