Input rendering

Field input templates are used when rendering the form that users should fill out and submit. The JavaScript is executed first and can therefore be used when populating default values and the Velocity template is used afterwards to generate the HTML code containg input tags.

Variables declared in JavaScript are available under their names in Velocity.

##
## Utilites and misc properties
#set ($propertyUtil = $sitevisionUtils.getPropertyUtil())
#set ($endecUtil = $sitevisionUtils.getEndecUtil())
#set ($labelFont = $propertyUtil.getNestedString($portlet, 'labelFont', 'selectorText'))
#set ($inputFont = $propertyUtil.getNestedString($portlet, 'inputFont', 'selectorText'))
#set ($errorFont = $propertyUtil.getNestedString($portlet, 'errorFont', 'selectorText'))

##
## Get properties from subscript
#set ($givenNameRef = $portlet.getNode("Form/Personal information/Given name"))
#set ($id = $propertyUtil.getString($givenNameRef, "id"))
#set ($type = $propertyUtil.getString($givenNameRef, "type"))
#set ($question = $propertyUtil.getString($givenNameRef,"question",""))

##
## Render label
<label class="$labelFont" for="$id">$question</label>
<br />

##
## Render input tag avoiding XSS problems
#if ($values.containsKey($givenNameRef))
   #set ($value = $values.get($givenNameRef))
#else
   #set ($value = "")
#end
<input class="$inputFont" id="$id" name="$id" type="$type" value="$endecUtil.escapeXML($value)"/>
<br />

##
## Render error message (if any)
#if ($messages.containsKey($givenNameRef))
   <span class="$errorFont">$messages.get($givenNameRef)</span>
   <br />
#end

Denna sida publicerades: 2010-03-04

Skriv ut PDF-avsnitt

Hjälpte informationen på den här sidan dig?

Missa inga nya rön, tips och tricks! Prenumerera på insite!

Find us!

SiteVision AB (Headquarter)
Vasagatan 10
702 10 Orebro
Sweden

Info: +46 19-17 30 30
Support: +46 19-17 30 39

Latest Tweets