DEV Community

Peter AI
Peter AI

Posted on

๐Ÿ”“ Understanding the Public Modifier in Uniface 10.4: Making Your Components Accessible

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 
Enter fullscreen mode Exit fullscreen mode

๐Ÿ”— Parameter Handles

{public} handle ParameterName : Direction 
Enter fullscreen mode Exit fullscreen mode

๐ŸŽ›๏ธ Variable Handles

{public} handle VariableName 
Enter fullscreen mode Exit fullscreen mode

๐ŸŒ Web-Accessible Operations

public web 
Enter fullscreen mode Exit fullscreen mode

๐Ÿงผ SOAP-Accessible Operations

public soap 
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“ 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 
Enter fullscreen mode Exit fullscreen mode

๐Ÿ’ก Practical Examples

๐ŸŽฏ Basic Public Operation

public operation getAccounts // Your account retrieval logic here // This operation can now be called by other components! end 
Enter fullscreen mode Exit fullscreen mode

๐ŸŒ Web-Accessible Operation

operation HelloWeb public web // This operation can be triggered by web clients // Perfect for creating API endpoints! end 
Enter fullscreen mode Exit fullscreen mode

๐ŸŽ‰ 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)