Hello!
Not sure how to word what I am doing, so correct me please if I am wrong. Here is what I am trying to do. I have a xbl component with a bunch of fields and data, now some of these fields I want to be populated from a rest call to another service based off the values entered so far. I have the search and submission working, I get a list of results back that fit the search criteria. Now I want to way to copy (lets say the first result) back into the forms model. <xbl:binding id="workflow-episode-details" element="workflow|episode-details" xxbl:mode="lhha binding"> ... <xbl:template> <xf:model id="local-model"> <xf:instance> <episode-details> .... </episode-details> </xf:instance> <xf:submission id="dmr-test-submission" resource="http://localhost:8080/episode" method="post" ref="instance('episode-search-data')" serialization="application/xml" mediatype="application/xml" replace="instance" instance="episode-search-results" xxf:username="" xxf:password=""/> <xf:instance id="episode-search-data"> <episode-details/> </xf:instance> <xf:instance id="episode-search-results"> <results/> </xf:instance> </xf:model> </xbl:template> <xf:group id="workflow-component-group" model="local-model"> <xf:var name="binding" value="xxf:binding('workflow-episode-details')" /> .... <xf:trigger id="episode-search-buttom"> <xf:label>Search</xf:label> <xf:action ev:event="DOMActivate"> <xf:setvalue ref="instance('episode-search-data')/episodeId" value="$binding/EpisodeId"/> <xf:action ev:event="DOMActivate"> <xf:send submission="dmr-test-submission"/> </xf:action> <xf:action ev:event="DOMActivate" if="count-non-empty(instance('episode-search-results')/results) > 0"> <xf:setvalue ref="$binding" value="instance('episode-search-results')/results[1]"/> </xf:action> </xf:action> </xf:trigger> </xbl:binding> Some things to node, The list of results from the submission have an identically structure to the local-model, I am getting a list of results back and am currently just trying to copy the first result back into the binding. Thanks for your time in reading this and I hope is isn't to hard to read. Joel. -- Sent from: http://discuss.orbeon.com/ -- 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1558339254539-0.post%40n4.nabble.com. |
Administrator
|
Hi Joel,
It looks like the element bound your XBL control doesn't just contain text, but contains an `<EpisodeId>`. Is it expected to contain just 1 episode id? If so, I think it will be simpler to have that episode id directly as the value of the bound node. In that case, after the `<xf:send submission="dmr-test-submission"/>`, you'll want maybe to do: <xf:setvalue ref="$binding" value="instance('episode-search-results')/results[1]/EpisodeId"/> If `results[1]` contains multiple elements you want to insert, maybe you'll want do something like: <xf:delete ref="$binding/*"/> <xf:insert context="$binding" origin="instance('episode-search-results')/results[1]/*"/> Also, you don't need to have 2 `<xf:action ev:event="DOMActivate">`. You can just have 1, and move the content of the second one into the first one. You'll let me know if this helps, or if I missed your point. ‑Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- Sent from: http://discuss.orbeon.com/ -- 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1558460403450-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
In reply to this post by Joel Oates
Hello Alex,
Thanks for looking into it! So I was trying to replace a whole structure of type "Episode" which contains several elements, I took the approach you talked about, I deleted everything and replaced it with the instance. <xf:delete ref="$binding/*" /> <xf:insert context="$binding" origin="instance('episode-search-results')/results[1]/*" /> This worked wonderfully thank you. I am not sure if I should ask another question for this, but is there a way off the top of your head to create a way of being able to pick out of the results that I want to replace the instance with. My Use case is, I have done a "Search" and a list of results are returned, I want the user to click the one that they desire to replace the instance. Thanks Again for the reply. Cheers, Joel. -- Sent from: http://discuss.orbeon.com/ -- 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1558489173420-0.post%40n4.nabble.com. |
Administrator
|
Hi Joel,
Joel Oates wrote > This worked wonderfully thank you. Excellent! Joel Oates wrote > I am not sure if I should ask another question for this, but is there a > way > off the top of your head to create a way of being able to pick out of the > results that I want to replace the instance with. My Use case is, I have > done a "Search" and a list of results are returned, I want the user to > click > the one that they desire to replace the instance. You could maybe populate a dropdown with the results, let users select an item from the dropdown, and upon selection the `results` element corresponding to that item would replace what is in the `$binding` (which you now do when users click on the button). Would something along those lines make sense? ‑Alex ----- -- Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet -- Sent from: http://discuss.orbeon.com/ -- 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]. To view this discussion on the web visit https://groups.google.com/d/msgid/orbeon/1558718773516-0.post%40n4.nabble.com.
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Free forum by Nabble | Edit this page |