Main Content

Create Hyperlinks for Embedded Web View Report

To create one-way and two-way hyperlinks between the document pane and the web view embedded in the report, use these methods. These linking methods are inherited from the slreportgen.webview.EmbeddedWebViewDocument base class of the report generator.

  • createDiagramTwoWayLink — Create a two-way link between a document location and a diagram in the embedded web view. Clicking a link created by this method in the document opens the target diagram in the web view. Clicking in the diagram scrolls the document pane to the target document location.

  • createElementTwoWayLink — Create a two-way link between a document location and a diagram element in the embedded web view. Clicking a link created by this method in a document opens the diagram containing the model element and flashes the element. Clicking the element in the diagram scrolls the document pane to the target document location.

  • createDiagramLink — Creates a link from the document to a diagram in the embedded web view.

  • createElementLink — Creates a link from the document to an element of a block diagram in the embedded web view.

In the following example class, ExampleWebView, the fillcontent method uses createDiagramTwoWayLink and createElementTwoWayLink to create two-way links between the document panel and the embedded web view in an embedded web view report. To create one-way links from the document panel to the embedded web view, replace createDiagramTwoWayLink with createDiagramLink and createElementTwoWayLink with createElementLink.

classdef ExampleWebView < slreportgen.webview.EmbeddedWebViewDocument
        function wvdoc = ExampleWebView(reportPath,modelName)
            % Invoke the EmbeddedWebViewDocument constructor, which
            % saves the report path and model name for use by the
            % report's fill methods.
        function fillContent(wvdoc)
            % Fill the Content hole in the report template with design
            % variable information. You can use DOM or Report API methods
            % to create, format, add, and append content to this report.
            [~, handles] = getExportDiagrams(wvdoc);
            n = numel(handles);
            for i = 1:n
                diagHandle = handles{i};
                diagHeading = createDiagramTwoWayLink(wvdoc,diagHandle, ...
                blockFinder = slreportgen.finder.BlockFinder(diagHandle);
                while hasNext(blockFinder)
                    r = next(blockFinder);
                    elemHandle = r.Object;
                    elemHeading = createElementTwoWayLink(wvdoc,elemHandle, ...

This code creates an embedded web view report for the vdp model using the ExampleWebView class.

model = 'vdp';
wvdoc = ExampleWebView('myReport',model);

Here is the report:

Embedded web view report of the vdp model. The left pane contains the table of contents. The middle pane contains the diagrams and blocks in the model. The third pane contains the embedded Web View.

To use the links in the report:

  1. Click a diagram name in the document pane, for example, More Info. The associated diagram opens.

    More Info diagram, which contains "Model Description: The van der Pol Equation. This is a simulation of a nonlinear second order system."

  2. In the embedded web view, on the More Info tab, click vdp.

    More Info pane, with the mouse pointing to vdp.

    The vdp diagram opens and vdp is highlighted briefly in the document pane.

    Document pane showing the vdp link highlighted in yellow.

  3. Click Square in the document pane, the Square block is highlighted in the embedded web view.

    Square block name is selected and the Square block in the diagram is highlighted in blue.

  4. In the embedded web view, double-click the Mu block. The Mu link in the document pane is highlighted briefly.

    The Mu block is highlighted in blue in the vdp diagram. In the document pane, Mu is highlighted in yellow.

For other tasks to create your embedded web view generator, see:

To generate an embedded web view report, see Generate an Embedded Web View Report.

See Also

Related Topics