XRX/Selection List Management
From Wikibooks, the open-content textbooks collection
[edit] Motivation
You want every selection list in your form to be customized to the context of the situation. Selection lists need to be dynamically generated by a series of context aware services on the web server.
[edit] Method
XForms are powerful because they can load all the codes in a form from a single instance in the model.
This instance can have something like Sometimes you would like to customize what selection lists are displayed to a user based on their role or other property in their session such as what department or group they are associated with.
[edit] Method
This can be done by using session variables stored on the server. You can alternatively store the user in a cookie on the client and then use this information to look up the correct information.
Assume you have an XML file that associates a user with their roles:
<Users> <User> <LoginID>jdoe</LoginID> <Roles> <Role>project-manager</Role> <Role>glossary-code-table-admin</Role> </Roles> </User> <User> ... </Users>
These roles can be in a session variable (see session) or have a function that looks up the role from the LoginID.
When the forms load, a script can be executed that loads all the code tables into an instance in the model:
<xf:model> <xf:instanace src="all-codes.xq?LoginID=jdoe"/> </xf:model>