com.taursys.xml
Class TextField

java.lang.Object
  extended bycom.taursys.xml.Component
      extended bycom.taursys.xml.Parameter
          extended bycom.taursys.xml.AbstractField
              extended bycom.taursys.xml.TextField
All Implemented Interfaces:
DocumentComponent, Element, MapperComponent
Direct Known Subclasses:
HTMLTextArea

public class TextField
extends AbstractField

A component which can receive input and/or render a value to an XML document element. This component can function in three different ways, depending on the properties you set:

When used for output, the value is rendered in the XML document element as a text node by default. You can also render values to the element's attributes. This can be done by invoking the setAttributeValue method. The following example illustrates this:

 private TextField projectStatus = new TextField();

 private void jbInit() throws Exception {
   projectStatus.setId("projectStatus");
   ...
   this.add(projectStatus);
 }

 protected void openForm() throws Exception {
   ...
   projectStatus.setValue("on-schedule");
   projectStatus.setAttributeValue("bgcolor","green");
   ...
 }
 

After rendering the HTML document would appear as follows:

 ...
 <table>
   <tr>
     <td id="projectStatus" bgcolor="green">on-schedule</td>
     ...
 

When used for input, this component receives its value from the InputDispatcher AFTER the openForm method of the ServletForm by default. If you want this component to receive its input earlier (at the same time as Parameters), set the earlyInputNotify property to true.

By default, this component uses an internal DefaultTextModel with a VariantValueHolder and a default data type of String. You can specify a different data type when you invoke the constructor of this component. Below is an example:

   TextField salary = new TextField(DataTypes.TYPE_BIGDECIMAL);
 

This component can also be bound to an external ValueHolder. An external ValueHolder can be shared by multiple components. The propertyName specifies which property in the ValueHolder will be bound to this component. To bind this component, set the valueHolder and propertyName properties. You do not need to specify a data type when you bind to a ValueHolder. The following is an example of binding:

   TextField personId = new TextField(DataTypes.TYPE_INT);
   TextField lastName = new TextField();
   TextField city = new TextField();
   VOValueHolder holder = new VOValueHolder();

   private void jbInit() throws Exception {
     holder.setValueObjectClass(PersonVO.class);
     ...
     personId.setParameter("personId");
     personId.setId("personId");
     personId.setEarlyInputNotify(true);
     ...
     lastName.setId("lastName");
     lastName.setValueHolder(holder);
     lastName.setPropertyName("lastName");
     ...
     city.setId("city");
     city.setValueHolder(holder);
     city.setPropertyName("address.city");
     ...
     this.add(lastName);
     this.add(city);
   }

   protected void openForm() throws java.lang.Exception {
     holder.setValueObject(
         delegate.getPerson((Integer)personId.getValue());
     ...
   }
 

Notes: In the above example, the personId field is used as a parameter and display field. By setting its earlyInputNotify property to true, it will have its value available when the openForm method is invoked. It is not bound to the holder. The lastName field functions as a display only field. It is not configured as an input field. The same is true of the city field. Note the city field's property name: "address.city". The PersonVO has an "address" property of type AddressVO. The AddressVO in turn has a "city" property. The dot notation supports multiple levels of indirection.

See Also:
ValueHolder, Parameter

Constructor Summary
TextField()
          Constructs a new TextField with a default model and renderer.
TextField(int javaDataType)
          Creates a new TextField with a DefaultTextModel and VariantValueHolder of the given type.
 
Method Summary
protected  VisibleRenderer createDefaultRenderer()
          Deprecated. The TextFieldRender is no longer used. A TextField now contains a TextNode which uses a TextNodeRenderer.
 VisibleRenderer getRenderer()
          Deprecated. The TextFieldRender is no longer used. A TextField now contains a TextNode which uses a TextNodeRenderer.
 void processRenderEvent(RenderEvent e)
          Responds to a render event for this component.
 void setModel(TextModel newModel)
          Sets the model used by this component.
 void setRenderer(VisibleRenderer newRenderer)
          Deprecated. The TextFieldRender is no longer used. A TextField now contains a TextNode which uses a TextNodeRenderer.
 
Methods inherited from class com.taursys.xml.AbstractField
addAttribute, addNotify, addTextNode, createAttribute, createAttribute, createAttribute, createBoundAttribute, createBoundTextNode, createTextNode, createTextNode, createTextNode, getAttribute, getAttributeName, getAttributeText, getAttributeValue, getElementDelegate, getId, getTextNode, getTextNodeText, getTextNodeValue, isEarlyInputNotify, processInputEvent, removeAttribute, removeAttribute, removeNotify, removeTextNode, removeTextNode, setAttributeName, setAttributeText, setAttributeValue, setEarlyInputNotify, setId, setTextNodeText, setTextNodeValue, setValueHolder, toString
 
Methods inherited from class com.taursys.xml.Parameter
createDefaultModel, createDefaultModel, getDefaultValue, getFormat, getFormatPattern, getModel, getParameter, getPropertyName, getText, getValue, getValueHolder, processParameterEvent, setDefaultValue, setFormat, setFormatPattern, setParameter, setPropertyName, setText, setValue
 
Methods inherited from class com.taursys.xml.Component
addEventType, addInputListener, addParameterListener, addRecycleListener, addRenderListener, addTriggerListener, dispatchEvent, fireActionPerformed, fireInputReceived, fireParameterReceived, fireRecycle, fireRender, getEventTypeList, getParent, isNotifySet, isVisible, lazyAddNotify, lazyRemoveNotify, processEvent, processRecycleEvent, processTriggerEvent, removeEventType, removeInputListener, removeParameterListener, removeRecycleListener, removeRenderListener, removeTriggerListener, setVisible
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextField

public TextField()
Constructs a new TextField with a default model and renderer. The default model, a VariantTextModel, is created via the createDefaultModel method in the Parameter superclass.


TextField

public TextField(int javaDataType)
Creates a new TextField with a DefaultTextModel and VariantValueHolder of the given type. See com.taursys.util.DataTypes for defined data type constants TYPE_XXXXXX.

Method Detail

createDefaultRenderer

protected VisibleRenderer createDefaultRenderer()
Deprecated. The TextFieldRender is no longer used. A TextField now contains a TextNode which uses a TextNodeRenderer.

Creates the default VisibleRenderer for this component. By Default this methos returns a new VisibleRenderer. Override this method to define your own VisibleRenderer.


processRenderEvent

public void processRenderEvent(RenderEvent e)
                        throws RenderException
Responds to a render event for this component. This method simply notifies any RenderListeners of the event.

Specified by:
processRenderEvent in class AbstractField
Parameters:
e - the current render event message
Throws:
RenderException - if problem rendering value to document

setRenderer

public void setRenderer(VisibleRenderer newRenderer)
Deprecated. The TextFieldRender is no longer used. A TextField now contains a TextNode which uses a TextNodeRenderer.

Sets the renderer subcomponent used to render the value to the Document.


getRenderer

public VisibleRenderer getRenderer()
Deprecated. The TextFieldRender is no longer used. A TextField now contains a TextNode which uses a TextNodeRenderer.

Returns the renderer subcomponent used to render the value to the Document.


setModel

public void setModel(TextModel newModel)
Description copied from class: Parameter
Sets the model used by this component. If the given model does not have a defined format, the format and pattern are copied from the old model.

Overrides:
setModel in class Parameter
Parameters:
newModel - to be used by this component.


Copyright © 2007 Martin T Phelan. All Rights Reserved.