uniface.Field
The uniface.Field object provides access to selected properties of the field that it represents. It is returned by the getField function of uniface.Occurrence.
Arguments
Function |
Description |
---|---|
getLabel() | Returns a uniface.Label object representing the label of the field. For more information, see uniface.Label. |
getName() | Returns the fully-qualified name of the uniface.Field in the form FIELD.ENTITY.MODEL. |
getShortName() | Returns the unqualified name of the current uniface.Field in the form FIELD. |
getType() | Returns a constant string denoting the object type: uniface.TYPE_FIELD. |
getParent() | Returns a uniface.Occurrence object that represents the parent of the current uniface.Field. For more information, see uniface.Occurrence. |
getInstance() | Returns the uniface.Instance in which the uniface.Field resides. |
isEqualTo() | Checks whether the uniface.Field object is the same as another uniface.Field object. |
Function |
Description |
---|---|
Returns the field's value. | |
setValue() | Sets the field value. |
getProperty() | Returns the value of one of the field's properties. |
setProperty() | Sets the value of one of the field's properties. |
clearProperty() | Restores the initial value of the specified property. |
getProperties() | Returns all of the field's properties as a JavaScript object. |
setProperties() | Sets several field properties. |
clearProperties() | Restores the initial widget properties of the field or occurrence. |
getValrep() | Returns the field's ValRep lis as a JavaScript object. |
setValrep() | Sets the field's ValRep list. |
getValrepArray() | Returns the field's ValRep lis as a JavaScript array |
setValrepArray() | Sets the field's ValRep list using a JavaScript array. |
getSyntaxProperty() | Returns the value of one of the field's syntax properties. |
setSyntaxProperty() | Sets the value of one of the field's syntax properties. |
clearSyntaxProperty() | Restores the initial value of the specified syntax property. |
getSyntaxProperties() | Returns all of the field's syntax properties as a JavaScript object. |
setSyntaxProperties() | Sets several field syntax properties. |
clearSyntaxProperties() | Restores the initial values of a field's syntax properties. |
getDeclarativeSyntax() | Returns a JavaScript object containing the declarative syntax of the field, with fields describing the syntax. |
getError() | Returns a uniface.SyntaxError object representing a field syntax error. For more information, see uniface.SyntaxError . |
getBoundElement() | Returns the outermost DOM node attached to the current field for a particular View. |
Addressing and Manipulating a Field
The following example obtains a field object (AMOUNT), conditionally changes its value, and sets a display property.
var vInstance = uniface.getInstance("MUSICORDER"); Get an instance of the DSP MUSICORDER. if (vInstance != null) { var cartEnt = vInstance.getEntity("CART.MUSICSHOP"); Get the top-level entity CART.MUSICSHOP. if (cartEnt != null) { // Get the CART occurrence (there should be only one). var cartOcc = cartEnt.getOccurrence(0); Get the occurrence of CART.MUSICSHOP. if (cartOcc != null) { // Get the first item in the Cart var itemEnt = cartOcc.getEntity("CART_ITEM.MUSICSHOP"); Get the child entity CART_ITEM.MUSICSHOP. if (itemEnt != null) { var itemOcc = itemEnt.getOccurrence(0); Get the first occurrence of CART_ITEM.MUSICSHOP. if (itemOcc != null) { var quantityFld = itemOcc.getField("AMOUNT.CART_ITEM.MUSICSHOP"); Get the field AMOUNT.CART_ITEM if (quantityFld != null) { var quantity = new Number(quantityFld.getValue()); Get the value of AMOUNT.CART_ITEM if (quantity > 5) { quantityFld.setValue("5"); // Five suffices... If the value is more than 5, change the value to 5. quantityFld.setProperty("style:color", "red"); // To make the user aware Set the color property to red to highlight the change. } } } } } } }
- Get an instance of the DSP MUSICORDER.
- Get the top-level entity CART.MUSICSHOP.
- Get the occurrence of CART.MUSICSHOP.
- Get the child entity CART_ITEM.MUSICSHOP.
- Get the first occurrence of CART_ITEM.MUSICSHOP.
- Get the field AMOUNT.CART_ITEM
- Get the value of AMOUNT.CART_ITEM
- If the value is more than 5, change the value to 5.
- Set the color property to red to highlight the change.