Starting form fields according to url parameters.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Starting form fields according to url parameters.

gabri124
Hello I am new working with Orbeon Forms. I have reviewed Orbeon Guides and I have not managed to find a way to call a form by passing parameters in the url, and that the form depending on the parameters fill in the fields with selected information from the database. Is there anyone who can help me or guide me where to look to configure the form to perform this work.

For example:

http://server/orbeon/fr/ApplicationName/FormName/new?cipCode=08191

Depending on the postal code, I have a database service that gets information from the database and service fill in the fields with this information. How I can collect and pass it this parameter database service?

Is there anyone that can indicate or lead to look at me to configure this?

Thanks in advance
Reply | Threaded
Open this post in threaded view
|

Re: Starting form fields according to url parameters.

jasenka
Here are the steps:
1. create a field cipCode that will be holding the value of your URL parameter (can be hidden by setting visibility to false() ), then in the Initial Value property of that field enter this:
xxforms:get-request-parameter('cipCode')

2. create a database service, and create a query that will use your parameter in the WHERE clause:
for example you need city and country from the same table, search by postal code
SELECT mytable.city as city, mytable.county as country FROM  mytable  WHERE myval = <sql:param type="xs:int" select="cipCode"/>

3. create action,
- set "React to" to Form Load,
- set service to the name of the service from step 2
- set database service parameter (use "+" icon to add): source control should be name of your field "cipCode", parameter number 1
- set response control values: in the Destination control select field City and in the Source XPath Expression for that field set following:
/*/row/city
If you have a single value returned by the query, you can use a dot instead of the prev. line.
Repeat the same for other values returned in your query, one thing to keep in mind is that in this field you should have everything in lower case, keep your values in the query the same way, do not use camel-case.

I hope this helps. Good luck!
Reply | Threaded
Open this post in threaded view
|

Re: Starting form fields according to url parameters.

Fredrik Lidstrom
Just a thought about:

jasenka wrote
1. create a field cipCode that will be holding the value of your URL parameter (can be hidden by setting visibility to false() ),
You might be able to use a variable instead of a field, so you don't have to worry about hidden elements floating around. http://wiki.orbeon.com/forms/doc/developer-guide/xforms-variables
Reply | Threaded
Open this post in threaded view
|

Re: Starting form fields according to url parameters.

gabri124
Thx Jasenka and frederik thank's for your help.I was looking for that instruction

xxforms:get-request-parameter('cipCode')


I have create a hidden variable with that instruction.

Thx another time for both