|VCV-Tags in XHTML Documents|
This section describes which kind of tags and attributes VCV provides for using in XHTML documents.
VCV supports two kinds of text inputs, Single Line and Multi Line. Note, that they may contain data you would not see as text, such as control characters, but VCV does not matter about it, it works on strings as character arrays.
These are the XHTML form elements of the
input tag with the types text and password, so this produces identical VCV code:
<input type="text" name="login" size="20" /> <input type="password" name="pwd" size="20" />
There are the following XHTML and VCV attributes for single line text boxes (there are some more XHTML attributes, but VCV does not care about them):
<input type="text" name="var_word" vcv:minlength="2" maxlength="7" />
This example means, that the content of
var_word has to be at least
2, but maximal
7 characters long.
There are some limitations of single line text boxes: Incoming special characters with an ASCII value below
0x20 will be replaced with the space character (ASCII char
That is, because the XHTML
input tag does not support characters such as newline (
0x0A) or tab (
input accepts these characters, but you cannot type them into the field, instead you need to copy&paste.)
This is a mapping for the XHTML element
<textarea name="text" rows="10" cols="50" vcv:length="512"> Text for setting an initial textarea content. </textarea>
A textarea is a bit more liberal than a Single Line text box, since it also allows tabs and newlines to be in the string, so there will not be any replacement of control characters.
VCV interprets the following attributes:
textareahas no XHTML attribute to specify a maximal content length, there is a VCV one. The attribute value is the number of characters (not bytes!) the field may contain. This is to support multibyte character data such as Unicode™, because a length of 20 may be 20 ASCII characters, but it may also be 10 UTF-16 ones.
XHTML knows two kinds of submit buttons,
input type="submit" and
The following declarations are the same in the VCV meaning:
<input type="submit" name="go" value="Let's go" /> <button type="submit" name="go" value="Let's go"> <!-- Here may also be an image or a - different text as given as value --> </button>
VCV processes the following attributes (as sent from the user agent):
registerButtonAction("btn_name", "btn_value", callback_handler)
The function referenced by
callback_handler is called if the submit button named btn_name has the value btn_value; it receives a reference to the VCV form object representing the submitting form.
XHTML knows two kinds of selection, the first one is a Multiple Choice, that means you can select one or more items out of a set. The second one we name here Choose One, so you can choose only item at once.
A multiple choice is given either by
input type="checkbox" (with the same name) or by
<input type="checkbox" name="multi" value="first" /> <input type="checkbox" name="multi" value="second" /> <input type="checkbox" name="multi" value="third" /> <select size="3" name="multi" mulitple="multiple"> <option value="first">1st</option> <option value="second">2nd</option> <option value="third">3rd</option> </select>
There is also a plain VCV (XML) syntax for declaring a multiple choice field in script code like PHP or ASP, if your CGI script dynamically creates the code for such a field:
<?php // php code generating a select or checkboxes ... ?> <vcv:choose-multiple name="multi" values-of="array" />
The advantage of this kind of XHTML enhancement is, that is a so-called empty XML tag, that browsers do not display, but VCV will parse it.
values-of attribute tells VCV that there exists a variable, that contains values used to validate the submitted selection.
Note that there is no starting
$ for Perl or PHP to be compatible with later reimplementations in C, Java, ….
This variable has to be either an array or an (object) method returning an array:
<vcv:choose-multiple name="multi" values-of="db_result->values()" />
This attribute can also be used in
select tags, if your CGI script generates only the
<select size="1" name="multi" multiple="multiple" vcv:values-of="arrayFunction()"> <php // arrayFunction() returns an array with the following options: foreach ... ?> </select>
The XHTML elements for choosing one of number of items are
input type="radio" and
select without the multiple attribute:
<input type="radio" name="one" value="first" /> <input type="radio" name="one" value="second" /> <input type="radio" name="one" value="third" /> <select size="3" name="one"> <option value="first">1st</option> <option value="second">2nd</option> <option value="third">3rd</option> </select>
There is also a direct VCV syntax for this kind of selection:
<% // asp code generating a radio group %> <vcv:choose-one name="one" values-of="myList" />
VCV collects two values of a selection:
selecttag you have to give the XML namespace prefix
vcv, too. As mentioned above, values-of does not require a ``plain'' variable, also a method call will do it. If using VCV for programming languages with so-called early bindings, you cannot use the ``just in time'' validation of your form object, instead you always have to generate (and compile) the validation code. This is also recommended for interpreted programming languages with late bindings, because it increases script execution time.
This is also a kind of
input tag: It is of type file:
<input type="file" name="patch" size="50" maxlength="1024" accept="text/*" />
application/octet-stream. VCV implementations should use magic files (as used by the common unix program file) to determine the content type, because this seems to be a very good technology.
The tag described in this subsection can be used for setting certain VCV options. The VCV-API offers also the setVCVOption() function for this.
<vcv:option name="optName" value="optValue" />
This document: $Id: xhtml-tags.pod,v 1.1 2005/07/22 16:28:03 robertbienert Exp $
See http://vcv.sourceforge.net/spec/ for the latest revision.
|VCV-Tags in XHTML Documents|