Dynamically change logo on form

8 views
Skip to first unread message

MANISH

unread,
Nov 25, 2019, 2:58:53 AM11/25/19
to Orbeon Forms
Hi Alex - I have an API which returns logo/images based on the request parameter. How do I place this logo on the form?

For ex ; If you pass a code 5012 - > it returns a cat image
                                   code 5013 - > it returns a dog image and so on....

how do I place an image on the form returned by this rest api?


Thanks

Alessandro Vernet

unread,
Nov 25, 2019, 12:10:56 PM11/25/19
to orb...@googlegroups.com
Hi Manish,

Quick question: does the API return the actual image, or an URL to the image
(e.g. in the body of a JSON or XML response)?

‑Alex

-----
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
--
Sent from: http://discuss.orbeon.com/

Alessandro Vernet

unread,
Nov 25, 2019, 12:39:55 PM11/25/19
to orb...@googlegroups.com
Also, where does the code come from (request parameter, field value,
somewhere else…)?

MANISH B

unread,
Nov 25, 2019, 6:17:50 PM11/25/19
to orb...@googlegroups.com
Code come from a request parameter and an actual image is returned

--
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 orbeon+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1574703846838-0.post%40n4.nabble.com.

Alessandro Vernet

unread,
Nov 26, 2019, 1:05:36 PM11/26/19
to orb...@googlegroups.com
Hi Manish,

Got it, so try the following:

1. Insert a Calculated Value control where you want the image to show. Have
it calculated as something like `concat(' <https://server/image-',
encode-for-uri(xxf:get-request-parameter('code')), '.png> ')`. Note the use
of `encode-for-uri()` to avoid XSS.
2. Check that when you run the form, the markup for the image shows
correctly.
3. Edit the source of the form to add on the `<xf:output>` that corresponds
to your control an attribute `mediatype="text/html"`.

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

Alessandro Vernet

unread,
Dec 3, 2019, 7:35:45 PM12/3/19
to orb...@googlegroups.com
Hi Manish, did you get a change to try adding a `mediatype="text/html"` on
`<xf:output>`? Is so, did it work for you?
Reply all
Reply to author
Forward
0 new messages