orbeon if statement in control

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

orbeon if statement in control

pumbosha
Hi,

I have my own control and I want to put there some input depending on the instance('sth') contains some string. I mean in pseudocode:

if (instance('sth')=='mystring') {
    <xf:input>
         <xf:label>Your name</xf:label>
    </xf:input>
}

Is it possible to do something similar in xforms? I want to show this input only if content of instance 'sth' equals 'mystring'.

regards
Reply | Threaded
Open this post in threaded view
|

Re: orbeon if statement in control

Erik Bruchez
Administrator
Yes, two ways:

1. In the model, with e.g. `<bind relevant="instance('sth') = 'mystring'">`

2. In the view, with:

    <xf:input ref="nodeToBind[instance('sth') = 'mystring']">

where `nodeToBind`is the XML node you were going to bind your control.

I hope this helps,

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

Re: orbeon if statement in control

pumbosha
Thanj You. But how can I use it in trigger. In configuration control I have an instance: instance('button_label'). And in view there is trigger:

<xf:trigger>
    <xf:label ref="instance('button_label')" />
    <xf:send ev:event="DOMActivate" submission="my-submission" />
</xf:trigger>

I want to show this trigger only if instance('button_label')!="". Trigger is not input, so I can't use your first solution. Unfortunately I don't know how to use second solution in my case
Reply | Threaded
Open this post in threaded view
|

Re: orbeon if statement in control

Erik Bruchez
Administrator
You can do the same with the trigger:

    <xf:trigger ref=.[instance('sth') = 'mystring']>

or use the context attribute to avoid binding the trigger:

    <xf:trigger context=.[instance('sth') = 'mystring']>

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

Re: orbeon if statement in control

pumbosha
Unfortunately when I'm doing like You writed there is an following error:
Fatal error: Open quote is expected for attribute "ref" associated with an  element type  "xf:trigger".
Reply | Threaded
Open this post in threaded view
|

Re: orbeon if statement in control

Erik Bruchez
Administrator
My bad, I didn't add the quotes, or maybe Nabble ate them. Try:

    <xf:trigger ref=".[instance('sth') = 'mystring']">

or:

    <xf:trigger context=".[instance('sth') = 'mystring']">

-Erik