DEV Community

Peter + AI
Peter + AI

Posted on

πŸ”’ Understanding Uniface's "partner" Modifier: Controlling Component Visibility

When working with Uniface applications, controlling the visibility and accessibility of operations and handles is crucial for maintaining proper encapsulation and security. Today, I'll dive into the partner modifier - a powerful feature that helps you keep your components secure and well-structured. πŸ›‘οΈ

This article is based on the Uniface Documentation 10.4, with assistance from AI to help structure and present this information clearly.

πŸ€” What is the "partner" Modifier?

The partner modifier is a declaration keyword in Uniface that restricts access to operations and handles, making them available only within the component itself. Think of it as Uniface's way of implementing private visibility - similar to private methods in other programming languages! πŸ”

πŸ“ Syntax and Usage

The partner modifier can be used in several contexts:

πŸ”§ Operation Statements

partner operation OperationName
Enter fullscreen mode Exit fullscreen mode

πŸ“‹ Parameters Block

partner handle ParameterName : Direction
Enter fullscreen mode Exit fullscreen mode

πŸ—‚οΈ Variables Block

partner handle VariableName
Enter fullscreen mode Exit fullscreen mode

🌐 Web Qualifier (Dynamic Server Pages)

partner web
Enter fullscreen mode Exit fullscreen mode

🎯 Where Can You Use It?

  • partner operation and partner handle: Available in all component types βœ…
  • partner handle: Can also be used for fields, global variables, and component variables πŸ“Š
  • partner web: Specifically designed for Dynamic Server Pages πŸ–₯️

πŸš€ Key Benefits

🏠 Component Encapsulation

When you declare an operation or handle with the partner modifier, it becomes accessible only within the component itself. This promotes better code organization and prevents external components from accidentally calling internal methods.

πŸ”’ Web Security

In Dynamic Server Pages, combining partner with the web keyword adds an extra security layer. It prevents operations, detail triggers, or OnChange triggers from being directly invoked from the client browser - a crucial security feature for web applications! πŸ›‘οΈ

⚠️ Important Note for DSPs

While partner web prevents direct browser invocation, the data specified in the scope declaration can still be included in DSP request-response exchanges of other triggers or operations. This gives you fine-grained control over what's accessible from the client side. πŸ“‘

πŸ’‘ Best Practices

  • Use partner for internal helper operations that shouldn't be called externally πŸ”§
  • Apply partner web to sensitive operations in Dynamic Server Pages πŸ”
  • Consider it as your "private" keyword equivalent in Uniface development 🏷️
  • Document your partner operations well since they're internal implementation details πŸ“š

πŸŽ‰ Conclusion

The partner modifier is an essential tool in the Uniface developer's toolkit for creating secure, well-encapsulated applications. Whether you're working with standard components or Dynamic Server Pages, understanding and properly using this modifier will help you build more robust and secure applications. πŸ†

Happy coding! πŸ’»βœ¨

Top comments (0)