Page Request

Templating System : API Reference

Summary

Transform, validate and report errors in the query parameters associated with a page request.

This API is an alternative to ad_page_contract which should usually be preferred if you have ACS installed.

Methods

template::request create

Initialize the data structure to store request parameters. Should be called at the start of any page that takes request parameters.

template::request set_param name 
                            -datatype datatype
                            -multiple
                            -optional
                            -validate { { expression } { message } }

Validates request parameter values and then sets a local variable. Values are transformed if a transformation procedure exists for the specified datatype (i.e. the components of a date are assembled into a single structure).

template::request get_param name

Returns the value (or values if the multiple is used) of the named parameter.

template::request is_valid error_url

Boolean procedure for determining whether any validation errors occurred while setting request parameters.

Example

request create

request set_param state_abbrev -datatype keyword -validate {
  { regexp {CA|HI|NV} $value } 
  { Invalid state abbreviation $value. }
}

request set_param start_date -datatype date
request set_param user_id -datatype integer -multiple

if { ! [request is_valid "/mytemplates/request-error"] } { return }

...

Note(s)