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 |
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 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]. |
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 |
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 |
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 |
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 |
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 |
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 |
normalize-space() solved problem. It works finally. Thank You very much!
regards Tom |
Administrator
|
Tom, excellent, I'm glad that worked, and thanks for the update.
Alex
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Free forum by Nabble | Edit this page |