XRX/Selection List Management

From Wikibooks, open books for an open world
< XRX
Jump to: navigation, search

Motivation[edit]

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.

Method[edit]

XForms are powerful because they can load all the codes in a form from a single instance in the model.

This for instance, if 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.

Method[edit]

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 you can 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>

Back: Data Element EditorNext: Customizing Selection Lists