Oracle ADF Model and Business Components API Reference 10.1.2 B14022-01

oracle.jbo.uicli.jui
Class JUTextFieldBinding

java.lang.Object
  extended byjava.util.AbstractMap
      extended byoracle.jbo.common.JboAbstractMap
          extended byoracle.adf.model.binding.DCControlBinding
              extended byoracle.jbo.uicli.binding.JUControlBinding
                  extended byoracle.jbo.uicli.binding.JUCtrlValueBinding
                      extended byoracle.jbo.uicli.binding.JUCtrlAttrsBinding
                          extended byoracle.jbo.uicli.jui.JUTextFieldBinding
All Implemented Interfaces:
java.awt.event.ActionListener, javax.swing.text.Document, java.util.EventListener, JUCtrlInputValueHandler, java.util.Map, StructureDef
Direct Known Subclasses:
JUFormattedTextFieldBinding

public class JUTextFieldBinding
extends JUCtrlAttrsBinding
implements javax.swing.text.Document, java.awt.event.ActionListener

JUTextFieldBinding is a lightweight Document model that implements binding a javax.swing.JTextComponent to an attribute in a row of a BC4J ViewObject.

See Also:
Row, JTextField, javax.swing.JTextComponent

Nested Class Summary
 
Nested classes inherited from class java.util.Map
java.util.Map.Entry
 
Field Summary
 
Fields inherited from class oracle.jbo.uicli.binding.JUCtrlValueBinding
ATTR_ATTRIBUTE, ATTR_ATTRIBUTE_DEF, ATTR_ATTRIBUTE_DEFS, ATTR_ATTRIBUTE_VALUE, ATTR_ATTRIBUTE_VALUES, ATTR_ATTRIBUTES, ATTR_DISPLAY_HINT, ATTR_INPUT_VALUE, ATTR_LABEL, ATTR_LABELS, ATTR_LABELSET, ATTR_MANDATORY, ATTR_PATH, ATTR_TOOLTIP, ATTR_UPDATEABLE, mHasInputVal, mInputVal, SEP_LIST_DISPLAY
 
Fields inherited from class oracle.adf.model.binding.DCControlBinding
ATTR_CURRENTROW, ATTR_DEF, ATTR_ERROR, ATTR_ERRORS, ATTR_FULLNAME, ATTR_ITER, ATTR_NAME, mInternalGet_KeyResolved, ROW_KEY_STR
 
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
 
Constructor Summary
JUTextFieldBinding(javax.swing.text.JTextComponent control, JUIteratorBinding iterBinding, java.lang.String attrName)
          Creates an instance of this binding object that binds a swing JTextComponent with an attribute for rows in a given Iterator binding.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Handles the actionPerformed event generated by the associated TextControl.
 void addControlToPanel(java.lang.Object panel, java.lang.Object layoutObject, java.lang.Object layoutCons)
          *** For internal framework use only ***
 void addDocumentListener(javax.swing.event.DocumentListener listener)
          Delegates to the Swing Document object of the associated text component.
 void addUndoableEditListener(javax.swing.event.UndoableEditListener listener)
          Delegates to the Swing Document object of the associated text component.
static javax.swing.text.Document createAttributeBinding(JUFormBinding formBinding, javax.swing.text.JTextComponent control, java.lang.String voInstanceName, java.lang.String voIterName, java.lang.String voIterBindingName, java.lang.String attrName)
          This method is used by the JDeveloper designtime wizards for binding a text component with an attribute of rows of a ViewObject/RowIterator.
 javax.swing.text.Position createPosition(int offs)
          Delegates to the swing Document object of the associated text component.
 java.lang.Object getControlModel(java.lang.Object control)
          Gets the associated View's model object.
 javax.swing.text.Element getDefaultRootElement()
          Delegates to the Swing Document object of the associated text component.
 javax.swing.text.Position getEndPosition()
          Delegates to the Swing Document object of the associated text component.
static javax.swing.text.Document getInstance(JUFormBinding formBinding, javax.swing.text.JTextComponent control, java.lang.String voInstanceName, java.lang.String voIterName, java.lang.String voIterBindingName, java.lang.String attrName)
          Deprecated. since JDeveloper 9.0.2
 int getLength()
          Delegates to the Swing Document object of the associated text component.
protected  javax.swing.text.Document getModelImpl(javax.swing.text.JTextComponent control)
          Returns the Document object that provides data for the given control.
 java.lang.Object getProperty(java.lang.Object key)
          Delegates to the Swing Document object of the associated text component.
 javax.swing.text.Element[] getRootElements()
          Delegates to the Swing Document object of the associated text component.
 javax.swing.text.Position getStartPosition()
          Method delegates to the swing Document object of the associated text component.
 java.lang.String getText(int offset, int length)
          Method delegates to the swing Document object of the associated text component.
 void getText(int offset, int length, javax.swing.text.Segment txt)
          Method delegates to the swing Document object of the associated text component.
 java.lang.Object getValueAt(int attrIndex)
          Fetches the text contained in the associated control.
 void insertString(int offset, java.lang.String str, javax.swing.text.AttributeSet a)
          Method delegates to the swing Document object of the associated text component.
protected  boolean isControlQueriable()
          Returns true, so that JTextComponents can participate in a query in the Find Mode of the containing panel.
 void putProperty(java.lang.Object key, java.lang.Object value)
          Method delegates to the swing Document object of the associated text component.
 void remove(int offs, int len)
          Method delegates to the swing Document object of the associated text component.
 void removeDocumentListener(javax.swing.event.DocumentListener listener)
          Method delegates to the swing Document object of the associated text component.
 void removeUndoableEditListener(javax.swing.event.UndoableEditListener listener)
          Method delegates to the swing Document object of the associated text component.
 void render(java.lang.Runnable r)
          Method delegates to the swing Document object of the associated text component.
 void setControl(java.lang.Object ctrl)
          Bind this binding to a control.
 void setDataValueAt(java.lang.Object value, int attrIndex)
          Applications should call this method to update the value of an attribute using this binding such that both the associated text control and the associated row attribute gets updated.
 void setValueAt(java.lang.Object value, int attrIndex)
          Sets the given String representation of value (using value.toString()) into the associated text control.
 
Methods inherited from class oracle.jbo.uicli.binding.JUCtrlAttrsBinding
createAttributeBinding, refreshControl, setControlEnabled, toString, updateNavigated, updateRangeScrolled, updateValuesFromRow, updateValuesFromRows
 
Methods inherited from class oracle.jbo.uicli.binding.JUCtrlValueBinding
compareAndSetAttribute, displayInShortForm, findAttributeDef, getAttribute, getAttribute, getAttribute, getAttributeCount, getAttributeDef, getAttributeDef, getAttributeDefs, getAttributeFromRow, getAttributeFromRow, getAttributeFromRow, getAttributeFromRow, getAttributeFromRow, getAttributeIndexOf, getAttributeNames, getAttributes, getAttributes, getAttributeUIHelper, getAttributeValidators, getAttributeValidators, getAttributeValue, getAttributeValue, getAttributeValueFromRow, getAttributeValues, getAttributeValues, getControlType, getDisplayHeight, getDisplayHint, getDisplayWidth, getError, getErrors, getHint, getHint, getInputValue, getLabel, getLabel, getLabels, getLabelSet, getLocaleContext, getMergedAttributeValues, getPath, getTooltip, getTooltip, hasFormatInformation, internalGet, internalGetRow, isArrayIteratorType, isAttributeMandatory, isAttributeUpdateable, isMandatory, isNewInputValue, isUpdateable, lookupAttributeDef, processInputException, processNewInputValue, put, release, resetInputState, setArrayIteratorType, setAttribute, setAttribute, setAttributeInRow, setAttributeInRow, setAttributeInRow, setAttributeInRow, setAttributeInRow, setAttributeInRow, setAttributeValue, setError, setInputValue, setInputValue, setInputValueHandler, stopEditing, updateRowDeleted, updateRowInserted
 
Methods inherited from class oracle.jbo.uicli.binding.JUControlBinding
getFormBinding, getIteratorBinding, reportException, setFormBinding
 
Methods inherited from class oracle.adf.model.binding.DCControlBinding
addToDCExceptions, executeQuery, executeQueryIfNeeded, get, getAllRowsInRange, getApplicationModule, getBindingContainer, getControl, getCurrentRow, getDCIteratorBinding, getDef, getDefFullName, getDefName, getFullName, getLayoutObject, getName, getRowAtRangeIndex, getRowIterator, getTransaction, getViewObject, hashCode, internalSetName, needsEstimatedRowCount, removeFromDCExceptions, reportException, resetAttributeExceptionInRow, setBindingContainer, setName
 
Methods inherited from class oracle.jbo.common.JboAbstractMap
entrySet, equals
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, isEmpty, keySet, putAll, remove, size, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface oracle.jbo.StructureDef
getDefFullName, getDefName, getFullName, getName
 

Constructor Detail

JUTextFieldBinding

public JUTextFieldBinding(javax.swing.text.JTextComponent control,
                          JUIteratorBinding iterBinding,
                          java.lang.String attrName)
Creates an instance of this binding object that binds a swing JTextComponent with an attribute for rows in a given Iterator binding. This binding object holds on to the Document object behind the JTextComponent control, if one is found. Otherwise, it attempts to set a PlainDocument as the document of the JTextComponent.

If this control is a JTextField, then this binding object also registers itself as an ActionListener so that when return key is pressed on the JTextField or whenever an ActionEvent is raised by the JTextField, this binding object responds by saving the text in the control into the BC4J Row object. The same save operation occurs on focus out from the control, as it also registers a FocusAdapter that performs the set operation on the BC4J Row object for the given attribute when focus moves out of this control.

JDeveloper wizards use the createAttributeBinding() method that returns a Document object to bind a ViewObject and attribute to a text control. An example usage for binding to Deptno attribute of DeptView ViewObject instance is like: jTextField2.setDocument(JUTextFieldBinding.createAttributeBinding(panelBinding, jTextField2, "DeptView", null, "DeptViewIter", "Deptno")); More details on the arguments can be found in the javadoc for the above method.

Parameters:
control - JTextComponent which should be bound to an attribute of a BC4J row.
iterBinding - JUIteratorBinding object that contains a reference to the RowIterator that contains Rows to display.
attrName - Name of the attribute in the BC4J Row object to display.
Method Detail

setControl

public void setControl(java.lang.Object ctrl)
Bind this binding to a control.

Overrides:
setControl in class DCControlBinding

getModelImpl

protected javax.swing.text.Document getModelImpl(javax.swing.text.JTextComponent control)
Returns the Document object that provides data for the given control. If no Document object is registered with the control, then this method creates an instance of PlainDocument and registers that as the Document object for the given control.


isControlQueriable

protected boolean isControlQueriable()
Returns true, so that JTextComponents can participate in a query in the Find Mode of the containing panel. When the containing panel Binding object is set to Find mode, it queries all control-bindings in it and disables those controls whose bindings return false for this method during the Find mode. The return value from this method indicates whether to consult an attribute definition for queriability.

An application could create a subclass of this binding object and return false from this method to prevent the associated control from participating in find mode. Additionally, a BC4J attribute itself can control whether that attribute can participate in Query or not. That property takes precedence over this method's return, if this method returns true. In other words, if this binding is bound to a CLOB attribute type and the attribute definition for that attribute indicates that it is not queriable, then the default behavior of JUPanelBinding in Find mode will be to disable this binding's control, even though this method returns true.

Overrides:
isControlQueriable in class JUCtrlAttrsBinding

addControlToPanel

public void addControlToPanel(java.lang.Object panel,
                              java.lang.Object layoutObject,
                              java.lang.Object layoutCons)
*** For internal framework use only ***

Overrides:
addControlToPanel in class JUCtrlAttrsBinding

getValueAt

public java.lang.Object getValueAt(int attrIndex)
Fetches the text contained in the associated control. This method is used by the framework to get the current value associated with this binding to update into the associated attribute of a BC4J Row. This method calls the JTextComponent.getText() to get the value.

Overrides:
getValueAt in class JUCtrlAttrsBinding
Parameters:
attrIndex - ignored for this control binding.
See Also:
javax.swing.JTextComponent#getText

setValueAt

public void setValueAt(java.lang.Object value,
                       int attrIndex)
Sets the given String representation of value (using value.toString()) into the associated text control. Calls JTextComponent.setText() to set the value. If the value is null, sets "" (an empty string) into the text control.

Overrides:
setValueAt in class JUCtrlAttrsBinding
Parameters:
value - The value to display in the associated text control.
attrIndex - Ignored for this control binding.
See Also:
javax.swing.JTextComponent#setText

setDataValueAt

public void setDataValueAt(java.lang.Object value,
                           int attrIndex)
Applications should call this method to update the value of an attribute using this binding such that both the associated text control and the associated row attribute gets updated.

Overrides:
setDataValueAt in class JUCtrlAttrsBinding
Parameters:
value - Value to display in the associated text control and to set in the attribute.
attrIndex - Ignored for this control binding.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Handles the actionPerformed event generated by the associated TextControl. Sets the associated attribute in this binding's iterator's current Row, with the current value from the text control.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

addDocumentListener

public void addDocumentListener(javax.swing.event.DocumentListener listener)
Delegates to the Swing Document object of the associated text component.

Registers the given observer to begin receiving notifications when changes are made to the document.

Specified by:
addDocumentListener in interface javax.swing.text.Document
Parameters:
listener - The observer to register.
See Also:
Document.removeDocumentListener(javax.swing.event.DocumentListener), Document

addUndoableEditListener

public void addUndoableEditListener(javax.swing.event.UndoableEditListener listener)
Delegates to the Swing Document object of the associated text component.

Registers the given observer to begin receiving notifications when undoable edits are made to the document.

Specified by:
addUndoableEditListener in interface javax.swing.text.Document
Parameters:
listener - The observer to register.
See Also:
UndoableEditEvent, Document

createPosition

public javax.swing.text.Position createPosition(int offs)
                                         throws javax.swing.text.BadLocationException
Delegates to the swing Document object of the associated text component.

This method allows an application to mark a place in a sequence of character content. This mark can then be used to tracks change as insertions and removals are made in the content. The policy is that insertions always occur prior to the current position (the most common case) unless the insertion location is zero, in which case the insertion is forced to a position that follows the original position.

Specified by:
createPosition in interface javax.swing.text.Document
Parameters:
offs - The offset from the start of the document >= 0.
Returns:
The position.
Throws:
javax.swing.text.BadLocationException - If the given position does not represent a valid location in the associated document.
See Also:
Document

getDefaultRootElement

public javax.swing.text.Element getDefaultRootElement()
Delegates to the Swing Document object of the associated text component.

Returns the root element that views should be based upon, unless some other mechanism for assigning views to element structures is provided.

Specified by:
getDefaultRootElement in interface javax.swing.text.Document
Returns:
The root element.
See Also:
Document

getEndPosition

public javax.swing.text.Position getEndPosition()
Delegates to the Swing Document object of the associated text component.

Returns a position that represents the end of the document. The position returned can be counted on to track change and stay located at the end of the document.

Specified by:
getEndPosition in interface javax.swing.text.Document
Returns:
the position
See Also:
Document

getLength

public int getLength()
Delegates to the Swing Document object of the associated text component.

Returns number of characters of content currently in the document.

Specified by:
getLength in interface javax.swing.text.Document
Returns:
Number of characters >= 0.
See Also:
Document

getProperty

public java.lang.Object getProperty(java.lang.Object key)
Delegates to the Swing Document object of the associated text component.

Gets properties associated with the document. Allows one to store things like the document title, author, etc.

Specified by:
getProperty in interface javax.swing.text.Document
Parameters:
key - A non-null property.
Returns:
the properties
See Also:
Document

getRootElements

public javax.swing.text.Element[] getRootElements()
Delegates to the Swing Document object of the associated text component.

Returns all of the root elements that are defined.

Typically there will be only one document structure, but the interface supports building an arbitrary number of structural projections over the text data. The document can have multiple root elements to support multiple document structures. Some examples might be:

Specified by:
getRootElements in interface javax.swing.text.Document
Returns:
the root element
See Also:
Document

getStartPosition

public javax.swing.text.Position getStartPosition()
Method delegates to the swing Document object of the associated text component.

Returns a position that represents the start of the document. The position returned can be counted on to track change and stay located at the beginning of the document.

Specified by:
getStartPosition in interface javax.swing.text.Document
Returns:
the position
See Also:
Document

getText

public java.lang.String getText(int offset,
                                int length)
                         throws javax.swing.text.BadLocationException
Method delegates to the swing Document object of the associated text component.

Fetches the text contained within the given portion of the document.

Specified by:
getText in interface javax.swing.text.Document
Parameters:
offset - the offset into the document representing the desired start of the text >= 0
length - the length of the desired string >= 0
Returns:
the text, in a String of length >= 0
Throws:
javax.swing.text.BadLocationException - some portion of the given range was not a valid part of the document. The location in the exception is the first bad position encountered.
See Also:
Document

getText

public void getText(int offset,
                    int length,
                    javax.swing.text.Segment txt)
             throws javax.swing.text.BadLocationException
Method delegates to the swing Document object of the associated text component.

Fetches the text contained within the given portion of the document.

Specified by:
getText in interface javax.swing.text.Document
Parameters:
offset - the offset into the document representing the desired start of the text >= 0
length - the length of the desired string >= 0
txt - the Segment object to return the text in
Throws:
javax.swing.text.BadLocationException - Some portion of the given range was not a valid part of the document. The location in the exception is the first bad position encountered.
See Also:
Document

insertString

public void insertString(int offset,
                         java.lang.String str,
                         javax.swing.text.AttributeSet a)
                  throws javax.swing.text.BadLocationException
Method delegates to the swing Document object of the associated text component.

Inserts a string of content. This will cause a DocumentEvent of type DocumentEvent.EventType.INSERT to be sent to the registered DocumentListers, unless an exception is thrown. The DocumentEvent will be delivered by calling the insertUpdate method on the DocumentListener. The offset and length of the generated DocumentEvent will indicate what change was actually made to the Document.

If the Document structure changed as result of the insertion, the details of what Elements were inserted and removed in response to the change will also be contained in the generated DocumentEvent. It is up to the implementation of a Document to decide how the structure should change in response to an insertion.

If the Document supports undo/redo, an UndoableEditEvent will also be generated.

Specified by:
insertString in interface javax.swing.text.Document
Parameters:
offset - the offset into the document to insert the content >= 0. All positions that track change at or after the given location will move.
str - the string to insert
a - the attributes to associate with the inserted content. This may be null if there are no attributes.
Throws:
javax.swing.text.BadLocationException - the given insert position is not a valid position within the document
See Also:
Document, DocumentEvent, DocumentListener, UndoableEditEvent, UndoableEditListener

putProperty

public void putProperty(java.lang.Object key,
                        java.lang.Object value)
Method delegates to the swing Document object of the associated text component.

Puts a new property on the list.

Specified by:
putProperty in interface javax.swing.text.Document
Parameters:
key - the non-null property key
value - the property value
See Also:
Document

remove

public void remove(int offs,
                   int len)
            throws javax.swing.text.BadLocationException
Method delegates to the swing Document object of the associated text component.

Removes a portion of the content of the document. This will cause a DocumentEvent of type DocumentEvent.EventType.REMOVE to be sent to the registered DocumentListeners, unless an exception is thrown. The notification will be sent to the listeners by calling the removeUpdate method on the DocumentListeners.

To ensure reasonable behavior in the face of concurrency, the event is dispatched after the mutation has occurred. This means that by the time a notification of removal is dispatched, the document has already been updated and any marks created by createPosition have already changed. For a removal, the end of the removal range is collapsed down to the start of the range, and any marks in the removal range are collapsed down to the start of the range.

If the Document structure changed as result of the removal, the details of what Elements were inserted and removed in response to the change will also be contained in the generated DocumentEvent. It is up to the implementation of a Document to decide how the structure should change in response to a remove.

If the Document supports undo/redo, an UndoableEditEvent will also be generated.

Specified by:
remove in interface javax.swing.text.Document
Parameters:
offs - the offset from the begining >= 0
len - the number of characters to remove >= 0
Throws:
javax.swing.text.BadLocationException - some portion of the removal range was not a valid part of the document. The location in the exception is the first bad position encountered.
See Also:
Document, DocumentEvent, DocumentListener, UndoableEditEvent, UndoableEditListener

removeDocumentListener

public void removeDocumentListener(javax.swing.event.DocumentListener listener)
Method delegates to the swing Document object of the associated text component.

Unregisters the given observer from the notification list so it will no longer receive change updates.

Specified by:
removeDocumentListener in interface javax.swing.text.Document
Parameters:
listener - the observer to register
See Also:
Document.addDocumentListener(javax.swing.event.DocumentListener), Document

removeUndoableEditListener

public void removeUndoableEditListener(javax.swing.event.UndoableEditListener listener)
Method delegates to the swing Document object of the associated text component.

Unregisters the given observer from the notification list so it will no longer receive updates.

Specified by:
removeUndoableEditListener in interface javax.swing.text.Document
Parameters:
listener - the observer to register
See Also:
UndoableEditEvent, Document

render

public void render(java.lang.Runnable r)
Method delegates to the swing Document object of the associated text component.

This allows the model to be safely rendered in the presence of currency, if the model supports being updated asynchronously. The given runnable will be executed in a way that allows it to safely read the model with no changes while the runnable is being executed. The runnable itself may not make any mutations.

Specified by:
render in interface javax.swing.text.Document
Parameters:
r - a Runnable used to render the model
See Also:
Document

getControlModel

public java.lang.Object getControlModel(java.lang.Object control)
Gets the associated View's model object.

Overrides:
getControlModel in class DCControlBinding

createAttributeBinding

public static javax.swing.text.Document createAttributeBinding(JUFormBinding formBinding,
                                                               javax.swing.text.JTextComponent control,
                                                               java.lang.String voInstanceName,
                                                               java.lang.String voIterName,
                                                               java.lang.String voIterBindingName,
                                                               java.lang.String attrName)
This method is used by the JDeveloper designtime wizards for binding a text component with an attribute of rows of a ViewObject/RowIterator. This method calls JUFormBinding.getRowIterBinding to get the iterator binding using the given parameters and then registers a new JUTextFieldBinding with the iterator binding object so as to display/edit the current row's attribute of the given name.

Parameters:
formBinding - The containing JUPanelBinding in which the given iterator binding would be found/created.
control - The control instance to bind to a ViewObject's attribute.
voInstanceName - Name of the instance of the ViewObject in a BC4J ApplicationModule.
voIterName - Runtime instance name of the iterator in the ViewObject (optional).
voIterBindingName - Instance name of the iterator binding that uniquely identifies an iterator binding object used to read/write data in this given JUPanelBinding instance.
attrName - The name of the attribute of this ViewObject rows that contains data to display/edit in the associated text control.
Returns:
Document object bound to the given text control.

getInstance

public static javax.swing.text.Document getInstance(JUFormBinding formBinding,
                                                    javax.swing.text.JTextComponent control,
                                                    java.lang.String voInstanceName,
                                                    java.lang.String voIterName,
                                                    java.lang.String voIterBindingName,
                                                    java.lang.String attrName)
Deprecated. since JDeveloper 9.0.2


Oracle ADF Model and Business Components API Reference 10.1.2 B14022-01

 

Copyright © 1997, 2004, Oracle. All rights reserved.