π This blog post was created with AI assistance to help explain Uniface concepts in simple terms.
Field widgets are the building blocks for displaying and editing data in Uniface applications. Think of them as the visual controls users interact with - like text boxes, dropdowns, or buttons. Let's explore how they work! π
What Are Field Widgets? π€
Field widgets represent scalar data values (single pieces of information). By default, if you don't choose a specific widget, Uniface uses a simple single-line edit box. It's like having a default pen when you don't specify which writing tool to use.
Different Types of Field Widgets π¦
Uniface 10.4 supports different widget types depending on where you use them:
1. Forms and Reports π
Form components support a wide variety of widgets - from simple text boxes to complex controls. Reports are more limited and only support non-editable EditBox and Picture widgets. This makes sense because reports are typically read-only documents.
Example: In a customer form, you might use an EditBox widget for the customer name, a dropdown list for country selection, and a date picker for the registration date.
2. Dynamic Server Pages π
These widgets are designed for web applications. They use HTML attributes for styling and can be controlled with JavaScript. This means you can update the interface without constantly asking the server for changes - making your web app faster and more responsive!
Example: You can use JavaScript functions like setProperty()
to change widget properties directly in the browser, such as enabling or disabling a submit button based on form validation.
3. Static Server Pages π
These are implemented as XHTML controls and don't support logical widgets (abstract widget definitions). You customize them by editing the server page layout directly.
Setting Widget Properties βοΈ
You have several ways to configure widget properties:
- Properties Inspector: Visual tool for all field widgets
- Initialization file: Configuration file settings
- ProcScript: Programming approach using commands like
$properties
and$fieldproperties
- JavaScript API: For dynamic server pages only
Example: Use $fieldproperties
to set widget properties for a specific field instance, or $paintedfieldproperties
to dynamically adjust the widget's size and position at runtime.
JavaScript API for Dynamic Control π»
For dynamic server pages, Uniface provides JavaScript functions that let you control widgets in real-time:
-
getProperty()
- Read a widget property value -
setProperty()
- Change a single widget property -
getProperties()
- Get all properties at once -
setProperties()
- Update multiple properties together -
clearProperty()
- Reset a property to its initial value -
clearProperties()
- Reset all properties to initial values
Example: When a user selects a checkbox to agree to terms, you can use setProperty()
to enable a previously disabled "Submit" button without reloading the page.
Special Note About Character Mode π₯οΈ
In character-based applications (text-only interfaces), regular widgets aren't supported. Instead, Uniface uses "Unifields" - special field representations that work the same way in both graphical (Windows) and character mode environments. This ensures your application works consistently across different platforms.
Key Takeaways π―
- Field widgets are visual controls for data input and display
- Different widget types exist for forms, reports, and web pages
- You can configure widgets through multiple methods (visual tools, code, or JavaScript)
- JavaScript APIs make web applications more responsive
- Character mode uses Unifields instead of widgets for compatibility
Understanding field widgets is essential for creating user-friendly Uniface applications. Whether you're building desktop forms or modern web applications, widgets give you the flexibility to create exactly the interface your users need! β¨
Top comments (0)