π This blog post was created with AI assistance to help Uniface developers understand widget customization better.
Hey Uniface developers! π Today we're exploring one of the most important aspects of creating user-friendly applications: choosing the right widget for your fields and entities. Let's dive into how Uniface 10.4 makes this process flexible and straightforward!
π€ What Are Widgets in Uniface?
A widget is the visual element that users interact with on the screen. Think of it as the "face" of your data. Instead of showing everything as a plain text box, you can use different widgets to make your application more intuitive and user-friendly. π―
By default, Uniface displays most fields as EditBox widgets (simple text input boxes). However, you have the power to change this to better match your data type and user needs!
π Common Widget Types
Here are some popular widgets you can use in Uniface 10.4:
- π€ EditBox - The standard text input field (default for most fields)
- βοΈ CheckBox - Perfect for yes/no or true/false values (default for Boolean fields)
- π DatePicker - A calendar control for selecting dates
- π DropDownList - A selection list for predefined options
- π RadioButton - Choose one option from several choices
π οΈ Where Can You Change Widgets?
Uniface gives you flexibility to define widgets at different levels. You can set them up once in your model and reuse them everywhere, or customize them for specific components. Let's explore both approaches! π
Option 1: Changing Widgets in a Modeled Entity
This is the recommended approach when you want consistency across your entire application. When you define a widget at the entity level, all components using that entity will inherit the same widget automatically. π¨
Step-by-step process:
- Open the Entity Editor in your Uniface IDE
- Select the entity or field you want to modify in the Structure panel
- Navigate to the Properties Inspector
- Find the Presentation properties section
- For each component type (like FRM for Forms, DSP for Dynamic Server Pages), choose your desired widget from the dropdown list
Real-world example: Imagine you have a field called "birthdate" in your PERSON entity. By default, it shows as an EditBox. You can change the FRM Widget Type to "DatePicker" in the entity model. Now, whenever you add this field to any form component, it will automatically appear as a calendar picker! π
Option 2: Changing Widgets in a Component
Sometimes you need different widgets for the same field in different contexts. Uniface allows you to override the entity-level widget settings directly in individual components. This gives you maximum flexibility! πͺ
How to do it:
- Open your component in the Component Editor
- Add a modeled entity and its fields to your component structure
- Select the field you want to customize
- In the Properties Inspector, find the Widget Type property
- Choose a different widget from the dropdown list (for example, DSP Widget Type for web pages)
Practical example: Let's say you have a "status" field that's usually a CheckBox in most forms. But for one specific reporting component, you want to show it as a DropDownList with options like "Active", "Inactive", and "Pending". Simply override the widget in that component without changing your entity model! β¨
π― Using Field Templates
For fields that aren't modeled (non-modeled fields), Uniface provides convenient field templates. These are pre-configured field definitions with specific widgets already assigned. π
How to use them:
- In the Component Editor, open the Templates tab
- Browse the available field templates (each template includes a widget type)
- Select the template that matches your needs
- Add it to your component structure or draw it directly on the canvas (for form components)
Example scenario: You're building a quick prototype and need to add an email field that doesn't exist in your entity model. Instead of creating a new entity field, you can grab an "Email" field template from the Templates tab, which already has the appropriate widget and validation configured. Quick and easy! β‘
π‘ Pro Tips for Widget Selection
- π― Match the data type: Use DatePicker for dates, CheckBox for booleans, DropDownList for limited options
- π Think about inheritance: Set widgets at the entity level for consistency, override at the component level for special cases
- π₯ Consider your users: Choose widgets that make data entry intuitive and error-free
- π± Platform matters: Some widgets may behave differently on web (DSP) versus desktop (FRM) components
- β Test thoroughly: Always verify that your widget choices work well with your data and business rules
π¬ Putting It All Together
Widget selection might seem like a small detail, but it makes a huge difference in how users interact with your application. By choosing the right widget for each field, you can:
- β¨ Create more intuitive user interfaces
- β‘ Speed up data entry
- π‘οΈ Reduce input errors
- π Improve overall user satisfaction
Remember: Uniface gives you the flexibility to define widgets once at the model level for consistency, or customize them per component when you need special behavior. Use this power wisely! π¦Έ
Now go ahead and experiment with different widgets in your Uniface 10.4 applications. Your users will thank you! π
Happy coding! π»β¨
Top comments (0)