SiteVision Onlinehelp
Search

Validation of values

When custom validation is disabled the standard field validation will be used. This means that if a subscript is mandatory and no value was submitted for that subscript, a message will be associated with the subscript and a re-rendering will be triggered.

If custom validation is activated is it possible to create an own JavaScript that validates the values submitted by users. A re-rendering of the form can be triggered by associating an error message with one or more subscript(s).

// Utilites and misc properties
propertyUtil = sitevisionUtils.getPropertyUtil();
givenNameRef = portlet.getNode("Form/Personal information/Given name");

// Make sure that a value exists
if (!values.containsKey(givenNameRef))
{
   message = propertyUtil.getString(givenNameRef, "customErrorMessage");
   messages.put(givenNameRef, message);
}

During validation is it also possible to associate values with subscript(s). This feature can be used when we want to associate values with subscript(s) that is provided by SiteVision (or another system) and not the user.

An example of this could be attribute stored in the portlet request or a property on the current user.

// Utilites and misc properties
propertyUtil = sitevisionUtils.getPropertyUtil();
portletContextUtil = sitevisionUtils.getPortletContextUtil();
currentUser = portletContextUtil.getCurrentUser();
givenNameRef = portlet.getNode("Form/Personal information/Given name");

// Don't trust the visitor, get given name from the current user
value = propertyUtil.getString(currentUser, "displayName");
values.put(givenNameRef, value);

Observe!
The map containing field values can only be modified during field validation.

Last updated:

se-sto-pio-sv5-1.sitevision-cloud.net
18.118.193.123