This example demonstrates how to create a web application with multiple pages by using multiple top-level WebVIs and Hyperlink controls to link between them. When you build the web application, each top-level WebVI generates a separate HTML file with links to the other HTML files that are generated.
- G Web Development Software
- Clone the ni/webvi-examples repository to your machine.
- Open
MultipleTopLevelVIs/MultipleTopLevelVIs.gwebproject
- On the Project Files tab, expand
WebApp.gcomp
and openindex.gviweb
- Click the Run button.
- Build the web application.
a. On the Project Files tab, double-clickWebApp.gcomp
to open the web application component.
b. On the Document tab, click Build.- To view the build output on your machine, click Output Directory on the Document tab once your application finishes building.
- To launch and view the Web Application locally you can use the Run button on the Document tab.
You can manually the move the build output found at \MultipleTopLevelVIs\Builds
to any web server. This project also includes a Distribution (WebApp.lvdist
) that can be used to build a package (.nipkg). Packages utilize NI Package Manager to automated the process of installing, upgrading, or removing the web app. A package is also a requirement for hosting a Web application on SystemLink Cloud.
The following steps can be used to host the web app on SystemLink Cloud
- Open
MultipleTopLevelVIs.gwebproject
- Open
WebApp.lvdist
- Click the build icon in the top command bar of this distribution document
- Open a Web browser and navigate to https://www.systemlinkcloud.com/webapphosting
- Click the Choose nipkg button and select the nipkg built in step 3.
- When the upload is complete, click on your newly uploaded Web app from your list of Web apps
The following steps can be used to host the web app on a local web server
- Open
MultipleTopLevelVIs.gwebproject
- Open
WebApp.lvdist
- Click the build icon in the top command bar of this distribution document.
- Double-click the nipkg and follow the on screen instructions.
- Open a web browser and navigate to
http://localhost:9090/incorporateuserresources/
- Open
C:\Program Files (x86)\National Instruments\Shared\NI WebServer\www
- Copy the
WebApp_Default Web Server
directory into thewww
directory. - Open a web browser and navigate to
http://localhost:8080/WebApp_Default%20Web%20Server/
- Open
C:\Program Files\National Instruments\Shared\Web Server\htdocs
- Copy the
WebApp_Default Web Server
directory into thehtdocs
directory. - Open a web browser and navigate to
http://localhost:9090/WebApp_Default%20Web%20Server/
Each of the top-level WebVIs generates a corresponding HTML file. The organization of the generated HTML files mirrors the hierarchy of WebVIs marked as top-level in the WebApp.gcomp
file.
On the Item tab, you can change the file name for each WebVI and view the relative URL used for linking.
Top-level WebVIs do not need to be at the root of the namespace. For example, SubVIs/Attribution.gviweb
is marked as top-level and has a relative URL of SubVIs/Attribution.html
.