Comments? Feedback?

This wiki does not yet support public comments (a limitation of Google Sites), so we encourage you to post your comments either:

On Twitter by responding to @orbeon.

On our community mailing list: subscribe sending an email to ops-users-subscribe@ow2.org (content of subject/body doesn't matter), you'll get a response with the email to use to send your message to the community mailing list.

Recent site activity

Access the value of a request parameter


The problem

You have a form to which you pass a request parameter, either on the URL with an HTTP GET, or through and form POST. You would like to access the value of that parameter from your form.

The solution

Assuming that the parameter name is my-parameter, you can access its value in XPath with xxforms:get-request-parameter('my-parameter'). However, you can only call this function on page load, not at a latter point. This means that you can use it in the Initial Value expression, but not on any of the other expressions you have in the Edit Validation Properties dialog. If you need to have access to that value to perform some validation or calculation:
  1. Create a new section in your form. Name it Internal, to reflect that its content won't be shown to users. For this in the Section Details dialog, under Visibility, enter false().



  2. Add a text output field in that section, and name it my-parameter. In the Validation Properties dialog for that field, in Initial Value, enter xxforms:get-request-parameter('my-parameter').

  3. Somewhere else in your form, you can access the value of the parameter in any expression as $my-parameter. For instance the example attached assumes the value of my-parameter is an integer, and shows the sum of that value and another value users enter in the form.

Get the source 

  1. Download request-parameter.xhtml, open it with a text editor, and copy its content.
  2. Create a new form in Form Builder, go to sidebar, and under Advanced choose Edit Source.
  3. Replace the source already there with the text you just copied.
  4. Deploy the form, go to the /new page, and add at the end of the URL ?my-parameter=42. Then if you enter, say, 2 in the text field and tab out, the text output will show 44 (42+2).

Č
ċ
ď
request-parameter.xhtml
(8k)
Alessandro Vernet,
Sep 27, 2011 7:12 PM