Report render lifecycle¶
Builds a report's xPression data XML (via the overridable Create) and renders it into document bytes through xPression, caching the rendered bytes so repeat calls avoid another round trip unless the caller requests an overwrite. This is the core rendering operation that Print and Save both depend on.
| Field | Value |
|---|---|
| Operation ID | OP-06 |
| Trigger | Render invoked directly, or transitively via Print/Save |
| Inputs | overwrite As Boolean = False, ReportPackage, OutputProfile, report XML from Create |
| Outputs | Boolean success; populates ReportFile (private m_reportFile) as a side effect |
| Primary components | ReportBase.Render, Create (overridable), clsSecurityPrincipal, clsPrint.previewDocument |
| Entry point | Public Function Render(Optional overwrite As Boolean = False) As Boolean |
Steps¶
- If a rendered file is already cached (
m_reportFileis notNothing) and the caller did not requestoverwrite, the operation skips re-rendering entirely —Createand xPression are not invoked again — and returnsTrueimmediately (BR-PRT-007). - Otherwise (no cached file, or
overwriterequested), calls the overridableCreate(overwrite)to (re)buildm_reportXml, which as a side effect clearsm_Errors. - Checks that
m_reportXmlis notNothingandReportPackage.Length > 0before proceeding — a report can be rendered only when its XML document exists and a report package is assigned (BR-PRT-008). - If the precondition fails: no rendering occurs, and the operation falls through to
result = False(the initial default) without adding an entry toErrors— this differs from the exception-catch path in step 6. - Resolves the default printer for the current
clsSecurityPrincipal, selecting the Web platform when_environmentService.IsWebisTrueand Windows otherwise, then setsxPrint.Printerto that value (BR-PRT-009). - Calls
xPrint.previewDocument(ReportPackage, m_reportXml.ToXpression, OutputProfile). -
The XML serialization consumed here is produced by
ToXpressionon the report'sXDesignXDocument.Origin: The
ToXpressionserialization is implemented by Build xPression XML, which handles key propagation, XML escaping, and self-closing empty elements. - The preview call itself is the same operation documented as Preview a document, including its package-name normalization.Origin: The
previewDocumentcall is implemented by Preview a document. 6. Assigns the returned bytes tom_reportFileand setsresult = True. 7. If any exception occurs anywhere in steps 2–6, it is caught, appended toErrorsasNew ErrorDetail("An error occurred while rendering the report.", ex), andresultremainsFalse— the exception is never rethrown (BR-PRT-010).
Process flow¶
flowchart TD
Start([Render called]) --> Cached{"reportFile set<br>AND not overwrite?"}
Cached -->|Yes| Ok1(["Return True<br>(cached, BR-PRT-007)"])
Cached -->|No| Create["Create() rebuilds XML"]
Create --> Pre{"xml set AND<br>package set?"}
Pre -->|No| Fail(["Return False<br>(no error added)"])
Pre -->|Yes| Platform["Resolve platform<br>Web/Windows"]
Platform --> DefPrinter["Get default printer"]
DefPrinter --> Preview["previewDocument<br>(→OP-01, ToXpression→OP-11)"]
Preview --> Store["Store ReportFile"]
Store --> Ok2(["Return True"])
Create -.->|exception anywhere| Err["Add ErrorDetail"]
Pre -.->|exception anywhere| Err
Platform -.->|exception anywhere| Err
Preview -.->|exception anywhere| Err
Err --> Fail2(["Return False"])
Failure and edge-case behavior¶
- Exceptions never propagate out of
Render; callers must inspectErrorsrather than rely on a thrown exception (BR-PRT-010). - The precondition-failure path (step 3) is distinct from the exception-catch path (step 7): a failed precondition produces
Falsesilently with noErrorDetailadded, whereas an exception during rendering does add one. A caller inspecting onlyErrorscould miss a precondition failure. xPrint(via theIReport.xPrintread-only property) lazily constructsclsPrintwith its parameterless constructor (New clsPrint()), which internally resolvesAppGlobal.EnvironmentServicerather than propagatingReportBase's own_environmentService— this directly affects the printer resolution performed in step 4.*
Related documentation¶
- Index
- Overview
- Architecture
- Dependencies
- Operations and processes
- Business rules
- Configuration
- API reference
Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.
Sources¶
SAIF.Services.Printing/Reporting/ReportBase.vbSAIF.Services.Printing/Reporting/IReport.vb