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

Data Addressing Functions

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.
Data Manipulation Functions

Function

Description

getValue()

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.
            }
          }
        }
      }
    }
  }
}

 

  1.  Get an instance of the DSP MUSICORDER.
  2.  Get the top-level entity CART.MUSICSHOP.
  3.  Get the occurrence of CART.MUSICSHOP.
  4.  Get the child entity CART_ITEM.MUSICSHOP.
  5.  Get the first occurrence of CART_ITEM.MUSICSHOP.
  6.  Get the field AMOUNT.CART_ITEM
  7.  Get the value of AMOUNT.CART_ITEM
  8.  If the value is more than 5, change the value to 5.
  9.  Set the color property to red to highlight the change.