Resource url

8 views
Skip to first unread message

Mani

unread,
Oct 21, 2020, 4:24:35 AM10/21/20
to Orbeon Forms
Hi Alex - Is it possible to change the resource url of a dynamic dropdown based on if-else condition.

<fr:databound-select1 xmlns="http://orbeon.org/oxf/xml/form-builder"
                                                  xmlns:xxbl="http://orbeon.org/oxf/xml/xbl"
                                                  id="control-4-control"
                                                  bind="control-4-bind"
                                                  appearance="search"
                                                  resource="if(count(for $x in tokenize($fr-search-value,'\s')) !=1) then https://www.google.com else https://www.google.co.in
                                                  ref=""
                                                  service-performs-search="true"
                                                  service-supports-paging="false"
                                                  is-last-page="">
                                <xf:label ref="$form-resources/control-4/label"/>
                                <xf:hint ref="$form-resources/control-4/hint"/>
                                <xf:alert ref="$fr-resources/detail/labels/alert"/>                        
                                <xf:itemset ref="">
                                    <xf:label ref=""/>
                                    <xf:value ref=""/>
                                </xf:itemset>
                            </fr:databound-select1>

Alessandro Vernet

unread,
Oct 21, 2020, 6:46:30 PM10/21/20
to orb...@googlegroups.com
Hi Manish,

Yes, you can use "Value Templates" (see link below), i.e. XPath between
curly braces, in that path. So something along these lines should work. And
you can have several of those in the same attribute, if needed.

resource="https://www.google.{ if(…) then 'com' else 'co.in' }"

https://doc.orbeon.com/xforms/core/attribute-value-templates

‑Alex

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

MANISH B

unread,
Oct 21, 2020, 8:56:34 PM10/21/20
to orb...@googlegroups.com
Below are the two url's that I require based on the if-else condition. If ' $fr-search-value is more than one word' then 'URL 1'  else ' URL 2' 

 URL 1. https://{xxf:property('username')}:{xxf:property('passwd')}@{xxf:property('url')}/employees?type=STAFF&resultPageSize=100&names={$fr-search-value}
 URL 2. https://{xxf:property('username')}:{xxf:property('passwd')}@{xxf:property('url')}/employees?type=STAFF&resultPageSize=100&first-name={$fr-search-value}&last-name={$fr-search-value}
  
For this to work I'm using the below resource Url which does not seem to work. Can you please let me know what am I doing wrong here?

Resource =
https://{xxf:property('username')}:{xxf:property('passwd')}@{xxf:property('url')}/employees?type=STAFF&resultPageSize=100&{if(count(for $x in tokenize($fr-search-value,'\s')) !=1) then 'first-name={(for $x in tokenize($fr-search-value,'\s') return concat('%25',$x,'%25'))}&last-name={(for $x in tokenize($fr-search-value,'\s') return concat('%25',$x,'%25'))}' else 'names={$fr-search-value}'}

Thanks

--
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/1603320388890-0.post%40n4.nabble.com.

Alessandro Vernet

unread,
Oct 22, 2020, 2:01:27 PM10/22/20
to orb...@googlegroups.com
Hi Manish,

Not really: how is it not working? Are you getting an error in the
`orbeon.log`? Is the service called, but with the wrong parameters? Or not
at all? I would try to simplify the URL, starting with something entirely
static, and adding to it little by little so you can see at every step what
could be causing the problem.
Reply all
Reply to author
Forward
0 new messages