PDF view for custom control in Orbeon forms

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

PDF view for custom control in Orbeon forms

rovsh
Hello,

What and how we should include in the XBL code of a custom control, so that it will be properly shown when forms is rendered in PDF?
Our custom control is moslty JavaScript based (a kind of autocomplete), however, when rendering the form in PDF, the field is shown as input field.

Thanks in advance.

-Rovsh
Reply | Threaded
Open this post in threaded view
|

Re: PDF view for custom control in Orbeon forms

rovsh
Hi,

Has anybody faced a similar issue and created a custom control and uses it in PDF generation?

Thanks in advance.

-Rovsh


rovsh wrote
Hello,

What and how we should include in the XBL code of a custom control, so that it will be properly shown when forms is rendered in PDF?
Our custom control is moslty JavaScript based (a kind of autocomplete), however, when rendering the form in PDF, the field is shown as input field.

Thanks in advance.

-Rovsh
Reply | Threaded
Open this post in threaded view
|

Re: PDF view for custom control in Orbeon forms

Erik Bruchez
Administrator
You can look at number.xbl as an example:

https://github.com/orbeon/orbeon-forms/blob/master/src/resources-packaged/xbl/orbeon/number/number.xbl

The following checks whether the control is in so-called "static readonly" mode:

<xf:var
  name="view"
  value="exf:readonly($binding) and property('xxf:readonly-appearance') = 'static'"/>

You can then use `$view` to conditionally show for example a simple output value when in that mode.

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: PDF view for custom control in Orbeon forms

rovsh
Hi,

Thanks for hint!
Now I am trying to process the output values. My control stores in XForms model selected values as a list delimited with space. E.g.: val1 val2 val3
I would like to iterate over these values and find a match in XML to get their labels. I have XML instance that I load using <xforms:submission>. To do this, I was trying to use XSLT in the following way:

                            <xsl:variable name="result">
                                <xsl:for-each select="tokenize($binding, '\s')">
                                    <xsl:value-of select="instance('suggestions-instance')//entry[value = .]/label" />
                                </xsl:for-each>
                            </xsl:variable>
                            <xf:var name="labels">
                                <xsl:value-of select="string-join($result, ',')"/>
                            </xf:var>
                            <xf:output id="readonly-value" ref="$labels" />

However, I ran into several issues here:
1) '$binding' variable is defined in XForms
2) XLST does not know about 'instance()' function, so I cannot access my instance defined with '<xforms:instance>'.

Can you please advice how to access variables declared in XForms inside XSLT?
Also, How can I access my instance declared with '<xforms:instance>' within XSLT?

Thanks a lot in advance.

-Rovsh
Reply | Threaded
Open this post in threaded view
|

Re: PDF view for custom control in Orbeon forms

Erik Bruchez
Administrator
You can't. They are completely separate. XSLT only applies statically when the component is created, like a template, and doesn't have any access to the XForms runtime such as variables or instances. Only the XForms is dynamic and re-evaluated as you go.

Try instead:

    <xf:var
        name="result"
        value="instance('suggestions-instance')//entry[value = tokenize($binding, '\s+')]/label/string()"/>

-Erik