How to react to a language change in a dropdown database service
<p>I have a form with a dropdown selection for the municipalities.<br>
Italian users see the italian names, german users the german names.<br>
Changing the language of the form works smootly, the names are instantly updated. </p>

<pre><code>&lt;resource xml:lang="de"&gt;
     &lt;gem&gt;
        &lt;label&gt;Ansuchen an die Gemeinde&lt;/label&gt;
        &lt;hint/&gt;
        &lt;item&gt;
            &lt;label&gt;Abtei&lt;/label&gt;                        
            &lt;value&gt;6&lt;/value&gt;
        &lt;/item&gt;
        ...
     &lt;/gem&gt;
&lt;/resource&gt;  
&lt;resource xml:lang="it"&gt;
    &lt;gem&gt;
        &lt;label&gt;Richiesta al Comune di:&lt;/label&gt;
        &lt;hint/&gt;
        &lt;item&gt; 
            &lt;label&gt;Aldino&lt;/label&gt; 
            &lt;value&gt;1&lt;/value&gt; 
        &lt;/item&gt;
        ...
     &lt;/gem&gt;
&lt;/resource&gt;  

&lt;fr:dropdown-select1 xmlns:xxbl="http://orbeon.org/oxf/xml/xbl" id="gem-control" bind="gem-bind"&gt;
    &lt;xf:label ref="$form-resources/gem/label"/&gt;
    &lt;xf:hint ref="$form-resources/gem/hint"/&gt;
    &lt;xf:alert ref="$fr-resources/detail/labels/alert"/&gt;
    &lt;xf:itemset ref="$form-resources/gem/item"&gt;
        &lt;xf:label ref="label"/&gt;
        &lt;xf:value ref="value"/&gt;
    &lt;/xf:itemset&gt;
 &lt;/fr:dropdown-select1&gt;
</code></pre>

<p>Now I saw in <a href="https://doc.orbeon.com/form-builder/database-services.html" rel="nofollow noreferrer">populating a dropdown</a>
that it is feasible to load the dropdown items from a database.<br>
I tried this and it functions, but the actual solution has the little flaw of an extra control on the form.</p>

<p>I created in the database a table with the three fields <code>gem</code>, <code>lang</code> and <code>gembeschr</code>.<br>
Example of the contents of the table:  </p>

<pre><code>gem    lang   gembeschr  
====== ====== =========    
 1     de     ALDEIN  
 1     it     ALDINO  
 ...  
</code></pre>

<p>In orbeon  in the database service then I used the following select:<br>
<code>SELECT gem, gembeschr FROM tablename where lang=&lt;sql:param type="xs:string" select=""/&gt;  order by gembeschr</code></p>

<p>But in all the examples I saw so far, the changes in the dropdown react to a control change on the form.<br>
So in the model I inserted the following <code>var</code> to establish the actual language of the form and used then this var in the calculate of a control:  </p>

<pre><code>&lt;xf:var name="langmmm"&gt; 
   &lt;xxf:value value="xxf:get-session-attribute('fr-language')"/&gt;
&lt;/xf:var&gt;   

&lt;xf:bind id="control-1-bind" name="control-1" ref="control-1" xxf:whitespace="trim" calculate="$langmmm"/&gt; 

 &lt;xf:output id="control-1-control" bind="control-1-bind"&gt;
     &lt;xf:label ref="$form-resources/control-1/label"/&gt;
     &lt;xf:hint ref="$form-resources/control-1/hint"/&gt;
     &lt;xf:alert ref="$fr-resources/detail/labels/alert"/&gt;
 &lt;/xf:output&gt;
</code></pre>

<p>And in the action then I specified this control in the observer:  </p>

<pre><code> &lt;xf:action event="xforms-value-changed xforms-enabled" ev:observer="control-1-control" if="true()"&gt;
     &lt;!-- Service to call --&gt;
     &lt;xf:send submission="gemeindeliste-submission"/&gt;
 &lt;/xf:action&gt;       
</code></pre>

<p>NB. I cannot change the visibility of control-1 to false(), because then the submission for the select will not be done anymore.</p>

<p>Is there a possibility to launch the select when the language of the form changes, without this additional control?             </p>

<p>Many thanks</p>