π‘ Note: This blog post was created with AI assistance to help explain Uniface concepts in simple terms.
π― What Are Component Entities?
In Uniface 10.4, a component entity is a data structure that defines what information your component works with. Think of it as a container that holds the data your application needs. Each component can have multiple entities, and how you organize them determines how Uniface processes your data at runtime.
When your application runs, each component entity becomes an occurrence - which is basically a living instance of your data structure that can be manipulated and used.
π§ Two Types of Component Entities
1. Template-Based Entities π¨
These are unique to your component and don't store data in a database. They're perfect for creating user interface controls or temporary data that doesn't need to be shared.
Example: Imagine you need a temporary calculation field that shows the sum of two other fields. You'd create a template-based entity for this because the result doesn't need to be saved to the database.
2. Derived Entities π
These are created from modeled entities and inherit their definitions, properties, and scripts. This ensures consistency across your application when multiple components access the same data.
Example: If you have a "Customer" entity defined in your data model, any component using customer data would create a derived entity from this model. All components will handle customer data the same way automatically.
π Inheritance and Overriding
Here's the cool part: while derived entities inherit everything from their parent model, you can still override specific properties or scripts locally in your component. When you do this, Uniface uses your local definition instead of the inherited one. This gives you flexibility when you need special behavior in specific components.
π What Are Component Fields?
A component field represents a single piece of data within a component entity. Just like entities, fields can be:
- Derived fields: Inherited from a modeled field π₯
- Local fields: Defined directly in your component π
Example: In a Customer entity, you might have fields like:
- CustomerName (derived from the model)
- CustomerEmail (derived from the model)
- DisplayLabel (local field just for this component's UI)
π¨ Widgets: Making Data Visual
The Widget property of a component field is what makes your data visible and interactive for users. It determines:
- How the field appears on screen π
- How users can interact with it π±οΈ
Different Interfaces, Different Widgets
Uniface supports various user interface types, each with its own widget set:
- Dynamic Server Pages: JavaScript-based widgets π
- Static Server Pages: HTML controls π
- Forms: Windows controls or Unifields (for character-based platforms) π»
Example: A "CustomerEmail" field could be displayed as:
- A text input box on a web page π§
- An editable field in a desktop form π
- A read-only label in a report π
βοΈ Configuring Widget Properties
Widget properties can be set in three places:
- Assignment File: Sets default values for all instances π
- Properties Inspector: Defines initial values when designing βοΈ
- Script: Changes values dynamically while your app runs π
Example: You might set a text field's maximum length to 50 characters in the Properties Inspector, but your script could disable the field based on user permissions at runtime.
π― Why This Matters
Understanding component entities and fields is fundamental to building Uniface applications because:
- Consistency: Derived entities ensure data is handled the same way across your entire application π
- Flexibility: You can override inherited behavior when needed for specific use cases π
- Reusability: Template-based entities let you create reusable UI patterns π
- Maintainability: Changes to modeled entities automatically propagate to all components using them π
π Getting Started
When building your next Uniface component:
- Identify what data you need π
- Decide if you need derived entities (for database data) or template-based entities (for UI controls) π€
- Choose appropriate widgets for your fields based on your user interface type π¨
- Set initial properties in the Properties Inspector βοΈ
- Add dynamic behavior through ProcScript when needed π»
By following these principles, you'll create well-structured, maintainable Uniface applications that are easier to develop and extend over time! π
Keywords: uniface, component, entities, widgets
Top comments (0)