Search these areas:
Help
Support Forums
Product Info



Introduction
DataWeb: What's New
Creating an Application
The DataWeb Designer
Application Management
Data Tables
Data Tables
Views
View Basics
Converting HTML Pages to Views
Incorporating Script in a View
-HotRAD Substitution Syntax
-Calling Functions
-The Record Object
View Property Reference
View XML Reference
URL Parameters Reference
SQL Expression Reference
Templates
Components
Data Analysis
Members
Security
Importing
Exporting
FTP
JavaScript
Object Model
Full-Text Search
Domain and Email Hosting
HotBlock Modules
Account Management
Glossary
New Responsive UI Module





DataWeb Help
Support Forums
Tutorial
Script Library
Knowledge Base

Home > Support

DataWeb User's Guide

DataWeb Substitution Syntax
Simple Pound Sign Delimiters: # #

An easy way to lend your application custom behavior is to use substitution syntax in conjunction with the predefined objects provided by DataWeb JavaScript, such as the User object, which provides information about the current user of the web application. For example, if you wish to provide a custom greeting for visitors to your web, place the following code within the source code of your view.

     Hello #user.name#.  Welcome to my web application.
Output:
     Hello john.  Welcome to my web application.

Inside of view files, code that appears within pound delimiters (# #) signals a script variable, expression, function or statement so that #user.name# outputs the current value of user.name.

Similarly, you can output the current date and time by using the prototype Date object, as in the following example.

     The current date and time are #Date()#.

You can use a similar technique to dynamically assign values to attributes within your view file. For example, to display a HTML block only to "John", you can use pound delimiters within the ws:htmlblock tag as in the follow example.

     <ws:htmlblock visible="#user.name=='john'#">

If the expression within the pound delimiters resolves to TRUE, then the HTML block will be displayed, if it resolves to FALSE, it will not displayed.

HTML Comment Delimiters: <!--# #-->

Oftentimes you will want to perform some operation in script and then output the result at some point within your view. In these cases, execute the operation within HTML comment delimiters (<!--# #-->) and then use pound delimiters (# #) to output the result of the operation later in the view.

     <!--#  
     var d = Date();
     d = d.getYear();
     d = d - 1776;
     #-->
     .
     .
     .
     It has been #d# years since 1776.

Output:

     It has been 225 years since 1776.

Note that HTML comment delimiters are used to prevent the final expression, d = d - 1776;, from being output to the view. If pound sign delimiters alone had been used, the value of d would have been output to the view twice, once by the expression d = d - 1776; and again by #d#.

Placement of script in a view

The placement of a script within a .view file depends on the sort of data that the script is designed to access.

If your script includes a reference to the record object, then place your script after the the <ws:dataregion> tag, since the values of the record object are defined only within or after the dataregion.

If you want your script to run before the body of the view is rendered, such as when your script contains conditional redirects to other pages, place your delimited script within the head tags of your view.

  <head>

<!--#

    var strFile = request.getParameter("TopicID");
    if(!strFile)
        response.throwRedirect("http://" + web.name + "." + web.domain
                + "/default.view?TopicId=37");    
#-->

  </head>
Otherwise, place your script after the opening body tag and before the opening ws:dataregion tag.
  <body>

<!--#  
var szgh = request.getParameter("_mode", ""); 
#-->
     
  <ws:dataregion>

References to the record object should appear after the ws:dataregion tag, and that data region must contain a ws:field tag for the referenced field.
  <ws:dataregion>
       <ws:field name="Email">
  .
  .
  .
  #record.Email#

CDATA Tags

To embed DataWeb Script in client-side script that's running in a view, put the script in substitution syntax within a CData tag, as follows:

   <script>
      <![CDATA[<!--
         #user.name#;
      //-->]]>
   </script>
Affiliate | Partner | Terms of Use | Privacy Policy | Contact Us | Pricing | Bring DataWeb In-House    
Email Us