As developers working with legacy systems and modern integration requirements, understanding how to properly expose functionality in Uniface is crucial for building maintainable applications. Today, let's dive deep into the public
modifier in Uniface 10.4! ๐
Note: This article is based on the official Uniface Documentation 10.4, and I had assistance from AI to structure this content.
๐ฏ What is the Public Modifier?
The public
modifier in Uniface is your gateway to component interoperability. It modifies declarations to indicate that operations or handles are available for external use and can be called by other components. Think of it as the "export" mechanism in modern programming languages! ๐ค
๐ง Syntax Variations
Uniface offers several ways to use the public modifier depending on your needs:
๐ Basic Operation Declaration
{public} operation OperationName
๐ Parameter Handles
{public} handle ParameterName : Direction
๐๏ธ Variable Handles
{public} handle VariableName
๐ Web-Accessible Operations
public web
๐งผ SOAP-Accessible Operations
public soap
๐ Where Can You Use Public Modifiers?
โ Universal Support
- public operation: Available in all component types
- public handle: Available in all component types, plus fields, global variables, and component variables
๐ Web-Specific Support
- public web: Dynamic Server Pages, Static Server Pages, and Service components
๐งผ SOAP-Specific Support
- public soap: Service components, Dynamic Server Pages, and Static Server Pages
๐ ๏ธ How It Works Under the Hood
๐ Component Signature Integration
When you declare an operation as public
, Uniface automatically includes it in the component signature. This means other components can discover and invoke these operations, enabling true component-based architecture! ๐๏ธ
๐ Web Integration
The public web
declaration is particularly powerful - it allows operations and triggers to be activated by:
- Browser requests ๐
- RESTful web services ๐
- Similar web clients ๐ฑ
๐งผ SOAP Integration
Using public soap
enables operations to respond to SOAP requests, perfect for enterprise integration scenarios where SOAP is still prevalent.
โ ๏ธ Important Gotchas
๐จ System Trigger Limitation:
System triggers cannot be declared with public web
access level. Attempting to do so will result in compilation error:
error: 1000 - Public web access is not permitted for system triggers
๐ก Practical Examples
๐ฏ Basic Public Operation
public operation getAccounts // Your account retrieval logic here // This operation can now be called by other components! end
๐ Web-Accessible Operation
operation HelloWeb public web // This operation can be triggered by web clients // Perfect for creating API endpoints! end
๐ Best Practices
- ๐ฏ Be Intentional: Only make operations public if they truly need external access
- ๐ Document Well: Public operations become part of your component's contract
- ๐ Security First: Consider authentication and authorization for web-accessible operations
- ๐งช Test Thoroughly: Public operations should be robust as they can be called from various contexts
๐ Conclusion
The public
modifier in Uniface 10.4 is a powerful feature that bridges the gap between component isolation and integration needs. Whether you're building internal component communications, web APIs, or SOAP services, understanding these modifiers is essential for modern Uniface development! ๐ช
Happy coding! ๐จโ๐ป๐ฉโ๐ป
Top comments (0)