$occproperties

Returns or sets the properties of an occurrence.

$occproperties(Entity {, Properties})

$occproperties(Entity) = PropertyList

Parameters

Parameters
Parameter Data Type Description
Entity String Entity name. If omitted, the current entity is used.
Properties String Uniface list of properties for which the value should be returned
PropertyList String Uniface associative list of Key = Property pairs, in which the Key can be:
  • errormsg—occurrence-level validation error message. This can contain default Uniface validation error messages, or it can contain user-defined error messages.
  • subclass—a style subclass used by server pages to present validation errors.
  • DspWidgetProperty—in Dynamic Server Pages only, a property that is supported by the AttributesOnly widget. For more information, see Entity and Occurrence Properties in Dynamic Server Pages.

Return Values

Associative list of properties.

Use

Allowed in all component types.

Description

$occproperties returns or sets the properties of an occurrence using an associative list.

Providing Error Messages in Web Applications

You can use subclass to provide visual clues for errors, and errormsg to provide detailed information on the nature of the error in a server page. To use $occproperties for this purpose, place it in the entity-level error trigger.

subclass=MyClass can be substituted by, or used with, a specific error message using errormsg=My Error Message

For example, when used together, the syntax is:

$occproperties(Entity)="subclass=MyClass;errormsg=My error message"

  • MyClass—predefined style class in the application’s CSS.
  • MyErrorMessage—message such as "Error in occurrence".

The syntax of $occproperties must not include spaces.

Note:  If the error trigger is empty, Uniface changes the default code from $text("%%$error") to $occproperties(Entity)="errormsg=$text(%%$error), but only if the trigger has been fired due to a validation error for a field or key.

Manipulating HTML Attributes for Occurrences in DSPs

In Dynamic Server Pages, you can use $occproperties to set the attributes of the HTML element in the layout that is bound to an occurrence in the runtime component. It is only possible to do this when the occurrence is bound to a single HTML element, not to a range of elements.

The properties that can be set in this way are the same ones supported by the AttributesOnly widget. For more information, see Entity and Occurrence Properties in Dynamic Server Pages.

For example, in a DSP in which each occurrence is bound to a table row (<tr>) element in the layout, you could highlight the occurrences that have been modified ($occstatus=""mod"). The following code adds a modified value to the HTML class attribute of occurrences that meet the condition. Any CSS style definitions that are defined for class modified are applied to the HTML elements bound to these occurrences.

if ($occstatus(<$entname>) = "mod")
  putitem/id $occproperties("<$entname>"), "class:modifed", "true"
endif

To reset the state of the attribute without knowing what classes were originally in it, you can precede it with an exclamation mark:

putitem $occproperties (myent), "!class:modifed"

For more information, see class:ClassName.

Related Topics