|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.taursys.xml.Component com.taursys.xml.Parameter com.taursys.xml.AbstractField com.taursys.xml.TextField
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:
parameter
property.id
property.parameter
and
id
properties.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.
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.Parameter |
createDefaultModel, createDefaultModel, getDefaultValue, getFormat, getFormatPattern, getModel, getParameter, getPropertyName, getText, getValue, getValueHolder, processParameterEvent, setDefaultValue, setFormat, setFormatPattern, setParameter, setPropertyName, setText, setValue |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public TextField()
public TextField(int javaDataType)
Method Detail |
protected VisibleRenderer createDefaultRenderer()
public void processRenderEvent(RenderEvent e) throws RenderException
processRenderEvent
in class AbstractField
e
- the current render event message
RenderException
- if problem rendering value to documentpublic void setRenderer(VisibleRenderer newRenderer)
public VisibleRenderer getRenderer()
public void setModel(TextModel newModel)
Parameter
setModel
in class Parameter
newModel
- to be used by this component.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |