UI Compatability

This module provides UI layout, grid, and AJAX capabilities to the BoxLang language, making it easy for you to migrate your CFML Applications to BoxLang.

📋 Table of Contents

✨ Features

  • 🎨 Layout Management: Tab, accordion, border, hbox, and vbox layouts with nested content areas

  • 📊 Data Grids: Sortable, editable data grids with pagination and column management

  • 🔧 AJAX Support: Client-server communication with JavaScript proxy generation and content loading

  • 🎯 Pod Containers: Flexible content containers with title bars and body areas

  • 📱 Responsive Design: Components adapt to different screen sizes and containers

  • 🔗 CFML Compatibility: Familiar syntax for Adobe ColdFusion and Lucee developers

  • 💪 Production Ready: Built by Ortus Solutions with enterprise-grade quality

  • 🚀 Zero Configuration: Sensible defaults get you started quickly

📦 Installation

Requirements

  • BoxLang 1.0.0 or higher

  • Web support enabled (for HTML generation and AJAX functionality)

  • bx-esapi module (automatically installed as a dependency)

Install via CommandBox

The module will automatically register and be available in your BoxLang applications with the following components:

  • bx:layout, bx:layoutarea - Layout management

  • bx:grid, bx:gridcolumn, bx:gridrow, bx:gridupdate - Data grids

  • bx:ajaxproxy, bx:ajaximport - AJAX functionality

  • bx:pod, bx:div, bx:tooltip - UI containers and elements

🚧 Rewrites CAUTION

If you are using a URL rewriting mechanism (like .htaccess for Apache or URL rewrite rules in Nginx), ensure that requests to static assets (JavaScript and CSS files) are properly routed. The module serves assets from the following paths:

Make sure these paths passthrough with no rewrites.

🚀 Quick Start

Here's how to create your first UI layout in just a few lines:

That's it! 🎉 You now have a tabbed interface with a dashboard and a data grid.

📚 Components Reference

Layout Components

📐 <bx:layout> Component

The main container component for creating structured layouts

Attributes

Attribute
Type
Default
Description

type

string

Required

Layout type: "tab", "accordion", "border", "hbox", "vbox"

align

string

""

Content alignment: "left", "center", "right", "justify"

fillHeight

boolean

false

Fill available height

fitToWindow

boolean

false

Fill entire window viewport

height

string

""

CSS height value (e.g., "400px", "50%")

width

string

""

CSS width value (e.g., "600px", "100%")

style

string

""

Additional CSS styles

id

string

auto-generated

HTML element ID

class

string

""

Additional CSS classes

name

string

""

Component name identifier

Layout Types

  • tab - Tabbed interface with clickable headers

  • accordion - Collapsible panels with headers

  • border - Five-region layout (top, bottom, left, right, center)

  • hbox - Horizontal box layout (flex row)

  • vbox - Vertical box layout (flex column)

📋 <bx:layoutarea> Component

Defines content areas within a Layout. Must be nested inside <bx:layout>.

Attributes

Attribute
Type
Default
Description

title

string

""

Area title (used for tabs/accordion headers)

align

string

""

Content alignment within the area

collapsible

boolean

true

Whether area can be collapsed (accordion)

initcollapsed

boolean

false

Start in collapsed state

source

string

""

URL to load content from (AJAX)

position

string

"center"

Position for border layout: "bottom", "center", "left", "right", "top"

size

string

""

CSS size for border layout regions

splitter

boolean

true

Show splitter for border layout

minsize

string

""

Minimum size constraint

maxsize

string

""

Maximum size constraint

id

string

auto-generated

HTML element ID

Grid Components

📊 <bx:grid> Component

Creates a data grid with sorting, editing, and pagination capabilities

Core Attributes

Attribute
Type
Default
Description

name

string

Required

Grid control name

query

query

null

Query object to populate the grid

pageSize

number

25

Number of rows per page

sortable

boolean

true

Enable column sorting

editable

boolean

false

Enable cell editing

autoWidth

boolean

false

Auto-size columns to fit content

height

string

""

Grid height (CSS value)

width

string

""

Grid width (CSS value)

stripeRows

boolean

true

Alternate row colors

showHeaders

boolean

true

Show column headers

selectMode

string

"single"

Row selection mode: "none", "single", "multi"

Event Attributes

Attribute
Type
Default
Description

onLoad

string

""

JavaScript function called when grid loads

onEdit

string

""

JavaScript function called when cell is edited

onSort

string

""

JavaScript function called when column is sorted

Styling Attributes

Attribute
Type
Default
Description

bgColor

string

""

Background color for grid

bold

boolean

false

Bold text formatting

colHeaderBold

boolean

false

Bold column headers

colHeaderFont

string

""

Column header font family

colHeaderFontSize

number

12

Column header font size

colHeaderItalic

boolean

false

Italic column headers

colHeaderTextColor

string

""

Column header text color

Advanced Attributes

Attribute
Type
Default
Description

bind

string

""

Data binding expression for AJAX

bindOnLoad

boolean

true

Whether to bind data on initial load

collapsible

boolean

false

Whether grid is collapsible

delete

boolean

false

Allow delete operations

appendKey

boolean

false

Append key field to form data

📋 <bx:gridcolumn> Component

Defines a column within a grid. Must be nested inside <bx:grid>.

Attributes

Attribute
Type
Default
Description

name

string

Required

Column name (maps to query column)

header

string

name

Column header text

width

string

"auto"

Column width (CSS value)

sortable

boolean

true

Enable sorting for this column

editable

boolean

false

Enable editing for this column

type

string

"string"

Data type: "string", "numeric", "date", "boolean"

format

string

""

Display format for values

align

string

"left"

Text alignment: "left", "center", "right"

🔄 <bx:gridrow> Component

Defines a data row within a grid (for manual data input)

🔧 <bx:gridupdate> Component

Handles grid update operations for editable grids

AJAX Components

🔗 <bx:ajaxproxy> Component

Creates JavaScript proxies for server-side components and executes bind expressions

Attributes

Attribute
Type
Default
Description

cfc

string

""

The CFC for which to create a proxy (dot-delimited path)

jsclassname

string

cfc name

Name for the JavaScript proxy class

bind

string

""

Bind expression for CFC method, JavaScript function, or URL

onError

string

""

JavaScript function to execute if bind fails

onSuccess

string

""

JavaScript function to execute if bind succeeds

📦 <bx:ajaximport> Component

Imports JavaScript and CSS files required for BoxLang AJAX tags and features

Attributes

Attribute
Type
Default
Description

tags

string

""

Comma-delimited list of BoxLang AJAX tags for which to import supporting files

cssSrc

string

"/bx-compat-ui/css"

URL of the directory containing CSS files

scriptSrc

string

"/bx-compat-ui/js"

URL of the directory containing JavaScript files

params

string

""

Parameters to pass, such as API keys

UI Components

🎨 <bx:pod> Component

Creates a container with optional title bar and body content

Attributes

Attribute
Type
Default
Description

title

string

""

Text to display in the pod's title bar

name

string

""

The name assigned to the pod control

height

string

""

Height of the control in pixels

width

string

""

Width of the control in pixels

bodyStyle

string

""

CSS style specification for the pod body

headerStyle

string

""

CSS style specification for the pod header

overflow

string

"auto"

How to display child content that overflows: "auto", "hidden", "scroll", "visible"

source

string

""

URL that returns the content of the pod

onBindError

string

""

JavaScript function to execute if bind expression results in error

📦 <bx:div> Component

Creates a flexible content container with AJAX loading capabilities

💬 <bx:tooltip> Component

Adds interactive tooltips to elements

🔧 Built-In Functions (BIFs)

AJAX BIFs

ajaxLink(url)

Generates a URL that causes link results to display within the current AJAX container rather than replacing the current page content.

Parameters

  • url (string, required) - The URL to load when the link is clicked

Return Value

Returns a JavaScript URL that handles AJAX loading into the nearest suitable container.

Examples

ajaxOnLoad(functionName)

Specifies a JavaScript function to run when a page loads in the browser.

Parameters

  • functionName (string, required) - The name of the JavaScript function to execute on page load

Return Value

Returns an empty string (outputs JavaScript to the page buffer).

Examples

Grid BIFs

queryConvertForGrid(query, page, pageSize)

Converts a query object to a format suitable for grid display with pagination and sorting.

Parameters

  • query (query, required) - The query object to convert

  • page (number, optional) - The page number (1-based, default: 1)

  • pageSize (number, optional) - The number of rows per page (default: 25)

Return Value

Returns a structure containing the converted grid data with pagination information.

Examples

💡 Examples

Layout Examples

📑 Tab Layout

💡 Use Case: Perfect for organizing related content into easily accessible tabs, like user interfaces with multiple sections.

🎯 Accordion Layout

💡 Use Case: Great for FAQ sections, help documentation, or any content where you want to conserve vertical space.

🎨 Border Layout

💡 Use Case: Ideal for complete application layouts with header, footer, sidebar navigation, and main content areas.

↔️ Box Layouts (HBox/VBox)

Horizontal Box Layout:

Vertical Box Layout:

💡 Use Case: Perfect for arranging content horizontally or vertically with consistent spacing and alignment.

Grid Examples

📊 Basic Data Grid

💡 Use Case: Perfect for displaying tabular data with sorting and pagination capabilities.

✏️ Editable Grid with Events

💡 Use Case: Ideal for administrative interfaces where users need to edit data directly in the grid.

AJAX Examples

🔗 AJAX Proxy for Server Communication

💡 Use Case: Perfect for creating rich client-server interactions without page refreshes.

🔄 AJAX Content Loading

💡 Use Case: Great for loading content dynamically while maintaining the overall page structure.

Complete Application Examples

🏢 Enterprise Dashboard

💡 Use Case: Complete enterprise application interface with navigation, data management, and analytics all in one unified interface.

🛒 E-commerce Admin Panel

💡 Use Case: Perfect for e-commerce administration interfaces with product management, order processing, and customer management all in one place.

🚀 Advanced Features

📊 Dynamic Data Loading

Components support AJAX data loading through the source attribute:

🎨 CSS Integration

All components generate semantic CSS classes for easy styling:

🔗 Event Handling

Components support comprehensive JavaScript event handling:

📱 Responsive Design

Layouts automatically adapt to different screen sizes:

❓ Troubleshooting

Components Not Rendering

Problem: Components appear as raw tags or don't render properly.

Solutions:

  • ✅ Ensure the module is installed: box install bx-compat-ui

  • ✅ Verify BoxLang web support is enabled

  • ✅ Check that component tags use the correct bx: prefix

  • ✅ Ensure required attributes are provided (e.g., type for layouts, name for grids)

AJAX Functionality Not Working

Problem: AJAX links or content loading fails.

Solutions:

  • ✅ Include <bx:ajaximport /> or <bx:ajaximport tags="layout,grid" /> in your page

  • ✅ Ensure URLs are accessible and return valid content

  • ✅ Check browser console for JavaScript errors

  • ✅ Verify that the BoxLang AJAX namespace is initialized

Layout Areas Not Displaying

Problem: Layout areas don't appear or appear incorrectly.

Solutions:

  • ✅ Ensure <bx:layoutarea> components are nested inside <bx:layout>

  • ✅ Check that position attributes are valid for border layouts

  • ✅ Verify title attributes are provided for tab and accordion layouts

  • ✅ Include appropriate CSS for styling (or use default CSS)

Grid Not Showing Data

Problem: Grid renders but shows no data or incorrect data.

Solutions:

  • ✅ Verify the query object has data: query.recordCount > 0

  • ✅ Check that column names in <bx:gridcolumn> match query column names

  • ✅ Ensure the query is properly passed to the grid's query attribute

  • ✅ Use queryConvertForGrid() if pagination is needed

Styling Issues

Problem: Components don't look right or lack styling.

Solutions:

  • ✅ Include component CSS files or create custom styles

  • ✅ Check for CSS conflicts with existing stylesheets

  • ✅ Use browser developer tools to inspect generated HTML and classes

  • ✅ Verify CSS classes are being applied correctly

JavaScript Errors

Problem: Interactive features not working, console shows errors.

Solutions:

  • ✅ Ensure <bx:ajaximport /> is included before using AJAX features

  • ✅ Check that JavaScript function names are spelled correctly in event attributes

  • ✅ Verify that referenced JavaScript functions are defined before components load

  • ✅ Use ajaxOnLoad() to ensure initialization happens at the right time

Performance Issues

Problem: Large grids or complex layouts are slow.

Solutions:

  • ✅ Use pagination with reasonable page sizes (25-50 rows)

  • ✅ Consider lazy loading for layout areas with source attribute

  • ✅ Optimize database queries that populate grids

  • ✅ Use autoWidth="false" for grids with many columns

Last updated

Was this helpful?