# OpenLink Virtuoso Universal Server: Documentation - variable

Chapter Contents | Prev | Next
Keyword Search:
www.openlinksw.com
docs.openlinksw.com
Book Home
Contents
Preface
Overview
Installation Guide
Quick Start & Tours
Sample ODBC & JDBC Applications
Conceptual Overview
Server Administration
Data Access Interfaces
SQL Reference
SQL Procedure Language Guide
Database Event Hooks
Data Replication, Synchronization and Transformation Services
Web Application Development
XML Support
RDF Database and SPARQL
Web Services
Runtime Hosting
Internet Services
Free Text Search
TPC C Benchmark Kit
Using Virtuoso with Tuxedo
Appendix
Virtuoso Functions Guide

## variable

Page variable - a user defined member of page class.
< variable name (required) type (required) default (optional) persist (optional) param-name (optional) xsd-stub-xhtml (optional) width (optional) height (optional) debug-srcfile (optional) debug-srcline (optional) debug-log (optional) />
Description

This element declares a data member for the page subclass corresponding to the containing page. The value of this data member can be preserved between consecutive postbacks. The attribute "persist" determine how to save the variable's value: to session table for inter-page usage, keep in page state only or do not keep it at all. Note that inter-page variable storage is available only when a vspx:login control is included on the page and authentication is performed; also the name of page variables in corresponding pages needs to be same. There is no special class for this control because only a data member will be added. Also the page defines two special variables 'sid' and 'realm' for login control. So when an existing login control is is in authenticated state, these will contain values for session id and application realm. Also every non-repeating control of the page will be represented as a page variable and thus be acessible as 'self.<name_of_control>' anywhere in the VSPX page after page initialization.

Attributes
name = SqlName

The name of page class member.

type = SqlName

The SQL data type of the variable.

default = SqlCode

The default value. Must be a literal scalar value suitable for the default clause of a user defined type member.

persist

Table: 12.4.9.1. Allowed values of the 'persist' attribute
session | keep the variable in the session; needs a login control to be present
pagestate | keep the variable in page view state
temp | do not keep variable
0 | same as 'pagestate'
1 | same as 'session'

param-name = SqlName

This specifies an optional name of a URL parameter for setting the page variable value. When this is specified and there is a parameter matching the name, the variable is set after it. This is a shorthand for an explicit call of keyword_get.

xsd-stub-xhtml

This attribute is for internal use only. It has no effect if added to the source VSPX file.

width

Visible width of the control when it is displayed in WYSIWYG tools when the source VSPX text is edited. The value of this attribute will not be used when the resulting HTML is rendered.

height

Visible width of the control when it is displayed in WYSIWYG tools when the source VSPX text is edited. The value of this attribute will not be used when the resulting HTML is rendered.

debug-srcfile

URI of the source document where the tag comes from.

debug-srcline

Line number in the source document where the tag comes from.

debug-log

This defines what sort of data are saved to the debugging log.

Examples
Declaration of page variable

<?xml version="1.0"?> <!-- - - $Id: variable__0.vspx,v 1.2 2006/08/16 00:04:15 source Exp $ - - This file is part of the OpenLink Software Virtuoso Open-Source (VOS) - project. - - Copyright (C) 1998-2006 OpenLink Software - - This project is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; only version 2 of the License, dated June 1991. - - This program is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - The v:variable element defines a new member of page class and hance we can access it with self.mask in rest of VSPX code.

    <v:page name="variable__0" xmlns:v="http://www.openlinksw.com/vspx/">
      <html>
        <head>
          <title>VSPX samples | v:variable</title>
        </head>
        <body>
          <v:variable name="mask" type="varchar" default="null"/>
          <?vsp self.mask := 'first value'; ?>
          <p>The variable value is set to '<?V self.mask ?>'</p>
          <?vsp self.mask := 'second value'; ?>
          <p>The variable value is set to '<?V self.mask ?>'</p>
        </body>
      </html>
    </v:page>