Client User Attributes
From Weave 2.6.5 onwards it’s possible to customise a client based on attributes associated with the user.
User attributes are custom values that are associated with a user, generally being read from a database table but can be provided in other ways. These values can be referenced in a client configuration to provide the value for any attribute in the configuration.
For example, if a user, or group of users, should be presented with an initial Table of Contents (ToC) for the map when they start a Weave client then the “toc” tag in that client configuration can be setup in such a way that the value for the name of the toc model to use can be provided by a user attribute.
<toc ref="${user.toc}"/>
Note this example assumes that a user attribute called “toc” has been associated with all users.
In the above example if the value for the “toc” attribute for the current user is “main” then the above would be the equivalent of:
<toc ref="main"/>
Default Values
If you can’t, or don’t to want to, set a value for an attribute for all users you can specify a default value for the attribute directly in the config. For example, if we wanted to use “main” as the default toc model, but have some users use something different, then you would use the following format:
<toc ref="${user.toc|main}"/>
If one user had the value “custom” for the toc attribute, it would be equivalent to:
If another user did not have a toc attribute at all it would be equivalent to:
Converting Values
Weave will try and guess the type of the value, either the attribute value or the default value, and convert the value to that type using the same rules that the config file reader uses when initially reading the values from the XML files. As such, there may be times when the conversion is incorrect. For example, if the value of the attribute is “1234”, Weave will convert that to the number 1234. So:
would result in the following object:
If the value is supposed to be a string and not a number, then you can override this by appending a colon followed by a format. For example, if the value of the user.number
attribute is 1234 but you need tag.value
to be a string you can explicitly specify the type of the value. So:
would result in the following object:
This is the same but provides a default in case the user does not have a number
attribute:
Note that type conversion only applies when the entire value is replaced by the user attribute. If the user attribute replacement is only part of the final value then it will always be treated as a string and the format will be ignored. For example:
would result in the following object: