I have form1 passing a query string parameter(param1) to form2. I pass param1=true from form1. In form 2, I am trying to set the value of the param1 into a local instance. If I DO NOT pass param1 from form 1, I want form2 to take the value of param1 to be false. Here is my instance.
<xforms:instance id="querystring-instance">
<query-string>
<param1></param1>
</query-string>
</xforms:instance>
I am using the following line to set the value of param1 by fetching it from the query string. If query string does not have param1, I want to use the default value of false.
<xforms:bind nodeset="instance('querystring-instance')/param1" calculate="xxforms:get-request-parameter('param1')" xxforms:default="false()" />
This does not work. If param1 is present it works and sets the in querystring-instance to true. If param1 is not present, it sets to nothing. I want it to be set to false. How do I do this?
You probably want to set the parameter upon initialization only, so use
xxforms:defaultinstead ofcalculate.calculatewill be evaluated at each XForms recalculate, and that will fail becausexxforms:get-request-parameter()is only available during XForms initialization.You can implement the condition in XPath.
xxforms:get-request-parameter()returns and empty sequence if the parameter is missing. This should work:What this does is that if
xxforms:get-request-parameter()returns an empty sequence, then the first value of the sequence will be ‘false’, and that’s what will be used to set the value.