Orbeon Form Builder - button with hyperlink with dynamic url

10 views
Skip to first unread message

Romek

unread,
Feb 14, 2020, 2:37:03 PM2/14/20
to orb...@googlegroups.com
Hi I'm completely new in orbeon action buttons. In Form Builder, I'd like to
be able to add a hyperlink control to a form, where the target URL (open in
a new window) is constructed partially from values available in other form
fields. When I add a button i have a source code:
<xh:td>
<fr:changeValueButton
xmlns:exf="http://www.exforms.org/exf/1-0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
id="test-control"
from=""
to=""
buttonLabel="label"
bind="test-bind"
class="">
<xforms:label
ref="$form-resources/test/label"/>
<xforms:hint
ref="$form-resources/test/hint"/>
<xf:alert
ref="$fr-resources/detail/labels/alert"/>
</fr:changeValueButton>
</xh:td>

I tried to follow some links like
https://stackoverflow.com/questions/21102328/orbeon-form-builder-hyperlink-with-dynamic-url
but i cannot force this button to open new site.
How to do it?
thanks
Romek

--
Sent from: http://discuss.orbeon.com/

Alessandro Vernet

unread,
Feb 14, 2020, 8:12:22 PM2/14/20
to orb...@googlegroups.com
Hi Romek,

We have an RFE to provide better support for this (#2037), on which I added
a +1 from you. For now, you'll need to do what follows. Start by adding a
"Calculated Value" control, and in the Control Settings / Formulas /
Calculated Value write the XPath to produce the HTML ` `. It will be
something like:

concat(
' Click me <https://www.google.com/',
$other-field-name,
'> '
)

You can then test the form, and check the produced HTML is correct:
html-link.png <http://discuss.orbeon.com/file/t119778/html-link.png>

Finally, edit the source of the form, locate the `<xf:output>` corresponding
to your Calculated Value, and add the attribute `mediatype="text/html"`.
(And we don't expose this last step in the UI, as if not done properly this
opens the door to possible script injections.)

You'll let me know if this works for you,

‑Alex

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

Alessandro Vernet

unread,
Feb 14, 2020, 8:14:13 PM2/14/20
to orb...@googlegroups.com
Mmh, the snippet in my previous message got mangled. So here is an image
instead:
xpath-generating-a.png
<http://discuss.orbeon.com/file/t119778/xpath-generating-a.png>

Romek

unread,
Feb 17, 2020, 2:24:23 PM2/17/20
to orb...@googlegroups.com
I dont have Calculated Value control but I did it with Text output control
and it works great!
Thank You for Your help
Best regards
Romek

Alessandro Vernet

unread,
Feb 17, 2020, 2:32:34 PM2/17/20
to orb...@googlegroups.com
Hi Romek, perfect. And sorry, I mean to refer to the Hidden Field control,
which was added in Orbeon Forms 2018.2, and before that you can indeed use a
Text Field, that you hide with Visibility under Formulas in the Control
Settings.

https://blog.orbeon.com/2019/02/hidden-fields.html

‑Alex

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

Romek

unread,
Feb 18, 2020, 3:33:20 AM2/18/20
to orb...@googlegroups.com
Alex is it possible to open this link in a new tab? Now it open link in the
same tab and its not easy to go back to form.
best regards
Romek Mendaluk

Alessandro Vernet

unread,
Feb 18, 2020, 6:38:20 PM2/18/20
to orb...@googlegroups.com
Hi Romek,

Yes: adding the attribute `target="_blank"` on that ` ` you create should do
the trick.

‑Alex

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

Romek

unread,
Feb 19, 2020, 10:06:57 AM2/19/20
to orb...@googlegroups.com
I have added this attribute in my form source but nothing changed

This is my control
xh:td>
<xf:output bind="sprawa-bind"
id="sprawa-control" mediatype="text/html" target="_blank"
class="">
<xf:label
ref="$form-resources/sprawa/label"/>
<xf:hint
ref="$form-resources/sprawa/hint"/>
<xf:alert
ref="$fr-resources/detail/labels/alert"/>

</xf:output>
</xh:td>

I did it correct?

Alessandro Vernet

unread,
Feb 19, 2020, 6:02:29 PM2/19/20
to orb...@googlegroups.com
Hi Romek,

Sorry for the confusion: the `target="_blank"` goes win the ` ` you generate
with XPath, along those lines:

https://gist.github.com/avernet/2a2c50d84116f2337b68c4c6acc730cc

‑Alex

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

Romek

unread,
Feb 20, 2020, 4:55:39 AM2/20/20
to orb...@googlegroups.com
Thanks, now it works great!!!

Romek

Alessandro Vernet

unread,
Feb 20, 2020, 5:48:08 PM2/20/20
to orb...@googlegroups.com
Perfect Romek, and thank you for the confirmation!

‑Alex

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

Alessandro Vernet

unread,
Mar 23, 2020, 1:38:14 PM3/23/20
to orb...@googlegroups.com
And Romek, I also added a +1 from you on request for enhancement #2037.

https://github.com/orbeon/orbeon-forms/issues/2037
Reply all
Reply to author
Forward
0 new messages