DEV Community

Peter + AI
Peter + AI

Posted on

πŸ“„ Understanding Uniface Static Server Pages (USP)

✨ This blog post was created with the assistance of AI to help explain Uniface concepts clearly.

Static Server Pages in Uniface 10.4 are a powerful component type for building web applications. Let me explain what they are and when you should use them.

🎯 What Are Static Server Pages?

A Static Server Page (USP) is a Uniface component that generates a complete web page every time it's activated. Think of it like this: whenever a user interacts with the page, the entire page gets recreated and sent back to the browser.

Example: Imagine you have a product catalog page. When a user clicks "Next Page," the server generates a completely new HTML page with the next products and sends it to the browser. The entire page refreshes, not just a small part of it.

πŸ”‘ Key Characteristics

Static Server Pages have several important features:

  • Full Page Updates: πŸ”„ The entire page reloads with each interaction. Unlike modern single-page applications, USPs don't support partial page updates.
  • Server-Side Processing: πŸ’» All the work happens on the server. The browser just displays what it receives.
  • HTTP Support: πŸ“‘ USPs can handle HTTP requests, making them great for file downloads and RESTful applications.
  • Simple Interaction: πŸ–±οΈ The only interactive trigger is the detail trigger on button widgets. This means users primarily interact through button clicks.
  • Synchronous Communication: ⏱️ When you send data to the server, you wait for the response before anything else happens.

βœ… When Should You Use USPs?

Static Server Pages are perfect for certain scenarios:

  • Relatively Static Content: πŸ“‹ Pages that don't change much or don't need frequent updates
  • Thin-Client Architecture: πŸ—οΈ Applications where all processing should happen on the server, not in the browser
  • RESTful Applications: πŸ”— Building REST APIs or services
  • File Upload/Download: πŸ“€ Handling file transfers

Example Use Case: A company intranet page showing employee policies. The content doesn't change often, and when an employee clicks to view a different policy section, a full page reload is acceptable.

🚫 Important Limitation

USPs cannot be used for mobile applications. If you're building a mobile app, you'll need to use a different Uniface component type.

βš™οΈ How USPs Work

The technical process is straightforward:

  1. Definition: You create a component definition and layout definition in the Uniface IDE
  2. Compilation: When compiled, Uniface creates a .usp file (the deployable file)
  3. Deployment: The .usp file is used to generate XHTML pages that browsers can display
  4. External Layouts: You can also use external layout files (.hts files) for more flexibility

Example: You build a contact form USP. After compiling, Uniface creates contact_form.usp. When a user visits your website, the server uses this file to generate the HTML page with your contact form.

🎨 Technical Details

USPs use proprietary XHTML tags to represent Uniface data structures in the layout. Widgets are implemented as standard HTML elements, making them compatible with all web browsers.

For advanced scenarios, you can configure the $SEARCH_SKELETON setting to use multiple layout definition files, giving you more control over how your pages are generated.

πŸ’‘ Summary

Static Server Pages are a reliable choice for traditional web applications where full page reloads are acceptable. They excel at:

  • Displaying static or semi-static content πŸ“Š
  • Handling server-side processing πŸ–₯️
  • Building RESTful services 🌐
  • Managing file operations πŸ“

While they may not be suitable for highly interactive modern web apps, they provide a simple, robust solution for many business applications.

Happy coding! πŸš€

Top comments (0)