5 Developing Worksheets for MapleNet
In this Chapter
5.1 Writing Worksheets for Use on MapleNet
MapleNet can display both standard and classic worksheets in a web browser, even if the worksheets have not been specifically designed for it. Content is static in any worksheet displayed by MapleNet, with the following exceptions.
When displayed by MapleNet, the embedded components provide means for a user to add new input to a worksheet.
The limitations imposed on worksheets displayed by MapleNet are as follows.
Worksheets that contain these disabled features can still be viewed on MapleNet, but the generated page may contain error messages indicating these operations are disabled. As a result, these worksheets may not function as expected.
When a worksheet is loaded by MapleNet, all autoexecutable commands are evaluated before that worksheet is displayed to the user. Therefore, the state of a worksheet when first opened by a user in MapleNet is the same as the state of the worksheet when opened and autoexecuted in Maple. As a result, the logic of a worksheet can be fully tested before being deployed to MapleNet.
Worksheets displayed on MapleNet are rendered with a fixed width. This width is specific to each worksheet and is set in Maple by changing the Math linebreaking width. This option is found on the Export tab of the Tools>Options dialog in Maple.
All relatively sized tables in the worksheet are scaled relative to this limit, and any content that is too large is scaled to fit. That is, changing the math formatting width has the same effect on worksheet layout as resizing the window in Maple. The math formatting width is converted to approximately 100 pixels per inch.
Tips to Improve Worksheet Layout
Refrain from using tables unnecessarily. If a table provides no useful formatting, it would be best to remove it. Placing content such as images, plots, or sketches inside table cells imposes size restrictions on these elements. When the table cells are scaled to the math formatting width, these restrictions may be undesirable and unnecessary.
Maple sketch regions are cropped, not resized, when placed inside table cells. MapleNet, however, will scale the sketch region to fit the cell. For sketches to be displayed the same in both instances, it is important to resize sketch regions in Maple to fit their table cells. To resize a sketch region in Maple, simply drag the sketch border.
Try to avoid scaling images. The scaling of images may introduce undesirable artifacts. It is best to generate images of the correct size and display them without scaling.
Tips to Improve Worksheet Performance
In a worksheet viewed on MapleNet, when an action is performed on an embedded component, a request is submitted to the server to execute the associated Maple code. However, if this action code is empty, no request is generated. This prevents unnecessary requests to the server. To take advantage of this optimization, if the action code of an embedded component does no real work, the code should be removed. Note that the default action code on a new component is not empty, even though its execution has no effect on the state of the worksheet.
Use collapsed sections to help improve the loading time of worksheets. If it is not necessary to have all the components visible when a worksheet is loaded, place any extraneous components in collapsed sections, to be expanded and accessed by the user as needed.
5.2 Passing Parameters to the Worksheet
MapleNet will allow URL request parameters to be passed to the worksheet when it is loaded the first time. In a URL of the form
the request parameters are
p = 10000
i = 5
t = 4.5
An alternate method to set request parameters is to create an HTML page with a Form object in it. The above URL could also be generated creating a web page, e.g., test.html and using the <form> tag as follows.<html> <head> <title>test</title> </head> <body> <h2>Data for test.mw</h2> <form method="post" action="test.mw" > <br>Principal: <input name="p" value=""> <Br>Interest: <input name="i" value=""> <Br>Term: <input name="t" value=""> <Br><input name="button1" value="Submit" type="submit"> </form> </body> </html>
When the Submit button on the web page is clicked, the current data associated with each <input> tag is converted to a request parameter (by the browser) and sent to the page defined by the action of the form, in this case the worksheet test.mw.
MapleNet will parse these parameters and create a Maple table of the form
_MapleNetWorksheetRequestParameters["p"] := "10000";
_MapleNetWorksheetRequestParameters["t"] := "5";
_MapleNetWorksheetRequestParameters["i"] := "4.5";
_MapleNetWorksheetRequestParameters["button1"] := "Submit";
The table _MapleNetWorksheetRequestParameters can be accessed from within the worksheet code.
5.3 Client Considerations
For a worksheet to have full functionality when viewed on MapleNet, the client's browser must support the following.
There are free, downloadable browsers available for recent versions of Windows, Macintosh, and UNIX/Linux operating systems.
In browsers without LiveConnect:
Plots, plot components, slider components, and math container components are all displayed as Java applets in the client web browser. As a result, the amount of memory available to these elements is limited by the client Java plug-in settings. This limit is configurable with a default value of approximately 100MB. This is more than enough memory for the applets themselves, but it does impose restrictions on the amount of data the applets can display.
If you are creating large worksheets, you may need to inform your users to increase the default limit.
Delay on First Use
As previously stated, plots, plot components, slider components, and math container components are displayed as Java applets. The first time a user accesses a worksheet containing these elements, there will be a delay as their browser automatically downloads the applets. Once these applets have been downloaded, they are cached and do not need to be downloaded for any other worksheets at the site. This cache is persistent between browser sessions.
5.4 Server Considerations
Each worksheet opened by each user requires a server-side representation of the worksheet in memory and an instance of the Maple kernel, just as it does in Maple. The memory and processing requirements of this representation are approximately the same as they are in Maple. These resources remain allocated to the worksheet until it is closed by the user (using the Close button in the worksheet interface) or until the user's session expires due to inactivity.
It is possible to increase the amount of memory available to MapleNet. For more details, refer to the Administration Guide or consult your site administrator.
5.5 Customization of the MapleNet Worksheet Interface
When worksheets are viewed on MapleNet, an interface to the web application is included in the header and footer of the page. It is possible to modify the look of this interface, but this customization requires a reconfiguration of the MapleNet server. For more details, please refer to the Administration Guide.
5.6 Publishing Worksheets to the MapleNet Server
Publishing a worksheet to the MapleNet server requires copying the worksheet file to the appropriate directory on the server. The file can be copied to the server using any network file transfer tool, such as FTP, SSH, or WebDAV.
Consult your site administrator for specific details on where your files should be placed and what method should be used to transfer them.
Once the file is copied to the server, your content will be available by accessing the appropriate URL. For example, if your worksheet is myworksheet.mw, then assuming the MapleNet server is myserver.com and that your worksheet was transferred to the worksheet directory of the MapleNet web application, the worksheet can be accessed by pointing your browser to http://myserver.com/maplenet/worksheet/myworksheet.mw.
Consult your site administrator for the exact URL to access your content.