WARNING: This tutorial is being written! Do not hesitate to report any errors or suggestions.
Imagine that all the pages of your web application must show the same information (for example a title banner). It would be a shame
to copy and paste the code of this title banner as many times as the number of pages. It is therefore preferable to define this banner in an
other file and to realize an inclusion of this file, and that as many times as necessary. Here is the way to follow.
-
Create a XML file to contain the part to include. This file must have a XML content (check by a DOM parser), it is mandatory
to have a single root node, as illustrated by the example below. Please note that the web components of the menu bars implementation
are used.
01 <?xml version="1.0" encoding="UTF-8" ?>
02 <div>
03
04 <h1 style="text-align: center">Web site name</h1>
05 <link rel="stylesheet" type="text/css" href="corelib/services/web/javascript/jwt/Jwt.css" />
06 <br />
07
08 <web:MenuBar>
09 <web:Menu text="File">
10 <web:MenuItem text="Open" url="License.wp" target="_blank" />
11 <web:MenuItem text="Save" url="License.wp" target="_blank" />
12 <web:MenuItem text="Save All" url="License.wp" target="_blank" />
13 </web:Menu>
14
15 <web:Menu text="Other">
16 <web:MenuItem text="???" url="License.wp" target="_blank" />
17 </web:Menu>
18
19 <web:Menu text="Help">
20 <web:MenuItem text="About ..." url="License.wp" target="_blank" />
21 </web:Menu>
22
23 </web:MenuBar>
24
25 </div>
File "ToInclude.xml"
-
Then you have to encode a Web page which includes the file previously defined. To do this, you need to use the tag
<include file="file.xml" /> (see line 09).
01 <?xml version="1.0" encoding="ISO-8859-1" ?>
02 <web:Html xmlns:web="corelib.services.web.components"
03 codeBehind="corelib.services.web.webapplications.WebPage">
04 <head>
05 <title>Master page</title>
06 </head>
07 <body>
08
09 <include file="ToInclude.xml" />
10
11 <!-- continue -->
12
13 </body>
14 </web:Html>
File "Master.wp"