Take the 2-minute tour ×

On a multi-language template I use a HTTP service to load a list of countries from a web service. The loading itself is done by an action that reacts to the Form Load event.

Since the names of the countries are different in each language, I would like to pass a parameter to the web service that specifies the language of the user. Another option would be to select the correct label after the list has been loaded.

Unfortunately I don't have any clue on how to achieve this. Any ideas ?

share|improve this question
Could you tell us if this for a form you created with Form Builder, or for a form that you wrote directly in XForms? –  avernet Sep 9 '11 at 19:05
This is a form created with Form Builder. –  dvgm Sep 12 '11 at 13:50

1 Answer 1

up vote 0 down vote accepted

I managed to pass the language to the web service by editing the source code manually. I added the language as web service request parameter with the following xml (added to the action).

<xforms:action context="instance('fr-service-request-instance')">
    <xforms:action class="fr-set-service-value-action">
        <xxforms:variable name="control-name" select="'requestor_country'" as="xs:string"/>
        <xxforms:variable name="path" select="//*:language" as="xs:string"/>
        <xforms:setvalue ref="$path" value="xxforms:instance('fr-language-instance')"/>

I still have one problem though, when the user switches language, the values are not loaded and the list is empty.

Currently the country list is loaded on the xforms-ready event. Which one should be used when switching language ?

share|improve this answer
Find the name of your submission (this is the id on the <xforms:submission>) and add, somewhere under <xforms:model> the following (which you can reformat as desired to make this more readable): <xforms:action ev:observer="fr-language-selector" ev:event="DOMActivate"><xforms:send submission="yahoo-weather-submission"/></xforms:action>. This will "listen" on users changing the language, and when they do also call your service. –  avernet Sep 12 '11 at 19:15
I can't get this to work. I've added the following just before </xforms:model> : <xforms:action ev:event="fr-language-selector" ev:observer="DOMActivate"> <xforms:send submission="Countries-submission"/> </xforms:action> where Countries-submission is the id of my submission. I checked the logs and found out the web service isn't called when switching language. –  dvgm Sep 13 '11 at 7:18
OK, let's take it step by step. First, let's see if the listener is called. If you add <xforms:action ev:observer="fr-language-selector" ev:event="DOMActivate"><xforms:message>Language changed</xforms:message></xforms:action> inside the <xforms:model>, then test the form, and switch language, do you see the message displayed? (I tried this with a 3.9 PE release build, and I do see it.) –  avernet Sep 13 '11 at 17:18
I'll do. Unfortunately I can't do this until wednesday next week. –  dvgm Sep 13 '11 at 19:06
OK, no problem; thanks for the update, and you'll let us know if this works. –  avernet Sep 13 '11 at 21:53

Your Answer


