How Page Scripts Work
Page scripts run on the Polarion server using the Apache Velocity template engine. The rendered output is then embedded into the Gantt widget as JavaScript. This means you can use Velocity expressions to access Polarion data (projects, users, plans, work items) and inject dynamic values into the Gantt configuration.Available Velocity Context Variables
The following objects are available inside page scripts:| Variable | Type | Purpose |
|---|---|---|
$project | Polarion project | Current project reference |
$user | Polarion user | Current logged-in user |
$trackerService | Polarion service | Query work items and plans |
$page | Wiki page | Current page reference |
config | Gantt config | Widget configuration object |
markerFactory | Marker factory | Create timeline markers |
Create a Baseline Comparison Page
This example creates a portal page that lists project baselines and opens the Gantt chart with a comparison overlay.-
Add a page parameter named
baselineRevisionof type string to your Gantt report page. -
In Widget Parameters > Advanced > Item Script, add the baseline loading logic:
-
Create a separate Wiki page with this Velocity snippet to list baselines:
Add Dynamic Markers with Velocity
Use themarkerFactory in the Markers Script to create timeline markers from Polarion data. For example, load iteration boundaries from plans:
Verify Your Changes
After saving the page, reload the Gantt chart. You should now see:- Baseline comparison bars rendered below current task bars (if a baseline revision is selected)
- Dynamic markers appearing as vertical lines on the Gantt timeline
- Velocity-generated values correctly resolved in the widget output
See Also
- Write Gantt Config Scripts for client-side global configuration
- Write Item Scripts for per-task customization
- Create Markers with Scripts for detailed marker scripting
- Compare Schedule with Baselines for baseline features
- Configure Page Parameters for page parameter setup
Sources
Sources
KB ArticlesSource Code
prod-gantt-src/com.nextedy.polarion.gantt/src/com/nextedy/polarion/gantt/model/impl/GanttScriptTransformer.javaprod-gantt-src/com.nextedy.polarion.gantt/src/com/nextedy/polarion/gantt/model/MarkerFactory.javaprod-gantt-src/com.nextedy.polarion.gantt/src/com/nextedy/polarion/gantt/model/impl/PlannedInFieldFilter.javaprod-gantt-src/com.nextedy.polarion.gantt/src/META-INF/hivemodule.xml