Trigger relevant

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

Trigger relevant

pumbosha
Hallo

I have following problem:

I have an instance named 'button_label'. Its value can contains name of button or empty string. It containst empty string when user doesn't want to display button, or some string when user want to display button with label equals this string. I want to reach this effect in following way:

<xf:trigger relevant="instance('button_label') != ''">
    <xf:label ref="instance('button_label')" />
    ...
</xf:trigger>

unfortunately when instance('button_label') equals '' or 'sth', trigger is displayed. Can someone know how to reach described effect?

regards,
Tom
Reply | Threaded
Open this post in threaded view
|

Re: Trigger relevant

Aaron Spike
Do you mind sharing what your instance looks like?

Have you tried debugging your condition using the XForms Inspector? http://wiki.orbeon.com/forms/doc/developer-guide/xforms-xforms-inspector

On Thursday, November 6, 2014 11:39:04 AM UTC-6, pumbosha wrote:
Hallo

I have following problem:

I have an instance named 'button_label'. Its value can contains name of
button or empty string. It containst empty string when user doesn't want to
display button, or some string when user want to display button with label
equals this string. I want to reach this effect in following way:

<xf:trigger relevant="instance('button_label') != ''">
    <xf:label ref="instance('button_label')" />
    ...
</xf:trigger>

unfortunately when instance('button_label') equals '' or 'sth', trigger is
displayed. Can someone know how to reach described effect?

regards,
Tom

--
View this message in context: <a href="http://discuss.orbeon.com/Trigger-relevant-tp4659200.html" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdiscuss.orbeon.com%2FTrigger-relevant-tp4659200.html\46sa\75D\46sntz\0751\46usg\75AFQjCNGzuegH2sJ8UABH9V0dEoZuCR4h6w';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fdiscuss.orbeon.com%2FTrigger-relevant-tp4659200.html\46sa\75D\46sntz\0751\46usg\75AFQjCNGzuegH2sJ8UABH9V0dEoZuCR4h6w';return true;">http://discuss.orbeon.com/Trigger-relevant-tp4659200.html
Sent from the Orbeon Forms community mailing list mailing list archive at Nabble.com.

This electronic communication, including any attached documents, may contain confidential and/or legally privileged information that is intended only for use by the recipient(s) named above. If you have received this communication in error, please notify the sender immediately and delete the communication and any attachments. Views expressed by the author do not necessarily represent those of Martin Luther College.

--
You received this message because you are subscribed to the Google Groups "Orbeon Forms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Reply | Threaded
Open this post in threaded view
|

Re: Trigger relevant

pumbosha
My instance:
<xf:instance id="button_label"><value/></xf:instance>

or when I put some value:
<xf:instance id="button_label"><value>sth</value></xf:instance>

I didn't try using any debugger
Reply | Threaded
Open this post in threaded view
|

Re: Trigger relevant

Alessandro  Vernet
Administrator
Hi Tom,

You want to write:

<xf:trigger ref=".[instance('button_label') != '']">

You can't put a relevant attribute on a trigger; only on an xf:bind which is the model. But you can achieve the same thing by binding the trigger to the current node, with a predicate which will be false when you want to hide the button, which is what the .[…] expression in the ref="…" does.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Trigger relevant

pumbosha
Thank You Alessandro

Unfortunately condition .[instance('button_label') != ''] always returns true, even if instance('button_label') equals empty String. Beside this, when I changed condition to:  .[instance('button_label') = 'someValue'] always returns false, even if instance('button_label') equals 'someValue'.
It looks like xforms reads instance value only once, and if user change value of instance, xforms doesn't notice this change.

regards
Reply | Threaded
Open this post in threaded view
|

Re: Trigger relevant

Alessandro  Vernet
Administrator
Hi Tom,

Mmh, that shouldn't be the case. Could you try adding just above the trigger, just for the purpose of debugging the following two lines:

<xf:output value="concat('X', instance('button_label'), 'X')"/>
<xf:output value="saxon:serialize(instance('button_label'), 'xml')" xmlns:saxon="http://saxon.sf.net/"/>

I'm curious to see what that returns in the case where the label is empty.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Trigger relevant

pumbosha
It looks like that empty value equals string " ". This results form outputs which I added:

X X <?xml version="1.0" encoding="UTF-8"?><value> </value>

and when instance contains value "someValue", it looks:

X someValueX <?xml version="1.0" encoding="UTF-8"?><value> someValue</value>

(space between 'someValue').

So I changed condition, and my trigger looks following:

<xf:trigger ref=".[instance('button_label')!=' ']">
    <xf:label ref="instance('button_label')" />
    <xf:send ev:event="DOMActivate" submission="my-submission">
        <xf:property name="resource" value="$resource"/>
    </xf:send>
</xf:trigger>

but unfortunately id still doesn't work.. Maybe some trim() function would be solution.

Regards

Reply | Threaded
Open this post in threaded view
|

Re: Trigger relevant

Alessandro  Vernet
Administrator
Hi Tom, one obvious question is: how come you have a space in <value>? I'd try to solve that first, so to simplify things. Like you said, you could test on normalize-space(instance('button_label')) != ''. That should work, but I think it's cleaner to avoid getting a space in there in the first place, if you can.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Trigger relevant

pumbosha
normalize-space() solved problem. It works finally. Thank You very much!
regards
Tom
Reply | Threaded
Open this post in threaded view
|

Re: Trigger relevant

Alessandro  Vernet
Administrator
Tom, excellent, I'm glad that worked, and thanks for the update.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet