I have a need to generate a nodeset dynamically in my XForms instance
based on xforms-value-changed event triggered when user selects an entry in a select1 drop-down. Can I use something like this: <xforms:bind nodeset="instance('pomocna')//systemy" calculate="xxforms:call-xpl ( 'oxf:/csp/users/edit_user/nacitaj- systemy.xpl', 'data', instance('main-instance')//zoznamy/ role/@selected, 'data' )"/> According to the XForms spec the expression in the "calculate" attribute should produce a value whereas the xxforms:call-xpl function will produce a nodeset. The xxforms:call-xpl function executes a db query which returns a nodest that I want to insert into the "instance('pomocna')//systemy" nodeset as a child of the "systemy" node. Possibly there is an alternative way to achieve my goal. A. -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Administrator
|
Alex,
Yes, @calculate always returns a string. There is just no way to change that. Instead of xforms:bind/@calculate, you can use xforms:insert/@origin. You have to figure out an appropriate time to run that action, and then your @origin attribute can call xxforms:call-xpl(). This is not perfect however, as @origin can return only a single node (in fact, I wonder whether this should be changed in XForms 1.2 - I just made a proposal to that effect as this is the second day in a row where I hit the requirement of copying multiple nodes with xforms:insert). As workarounds, I see without thinking too much: o Copying the root element returned by xxforms:call-xpl() into a temporary instance, and then using xforms:insert/@while to copy all the child elements to the destination instance o Using a submission with replace="instance" -Erik Alexander Zatko wrote: > I have a need to generate a nodeset dynamically in my XForms instance > based on xforms-value-changed event triggered when user selects an entry > in a select1 drop-down. Can I use something like this: > > <xforms:bind > nodeset="instance('pomocna')//systemy" > calculate="xxforms:call-xpl > ( > > 'oxf:/csp/users/edit_user/nacitaj-systemy.xpl', > 'data', > > instance('main-instance')//zoznamy/role/@selected, > 'data' > )"/> > > According to the XForms spec the expression in the "calculate" attribute > should produce a value whereas the xxforms:call-xpl function will > produce a nodeset. The xxforms:call-xpl function executes a db query > which returns a nodest that I want to insert into the > "instance('pomocna')//systemy" nodeset as a child of the "systemy" node. > > Possibly there is an alternative way to achieve my goal. > > A. > > > > > ------------------------------------------------------------------------ > > > -- > You receive this message as a subscriber of the [hidden email] mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > ObjectWeb mailing lists service home page: http://www.objectweb.org/wws -- Orbeon - XForms Everywhere: http://www.orbeon.com/blog/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Erik, how would I copy the root returned by the xxforms:call-xpl()
function (as in the first option you proposed)? A. On Oct 19, 2006, at 3:25 PM, Erik Bruchez wrote: > Alex, > > Yes, @calculate always returns a string. There is just no way to > change that. > > Instead of xforms:bind/@calculate, you can use xforms:insert/ > @origin. You have to figure out an appropriate time to run that > action, and then your @origin attribute can call xxforms:call-xpl > (). This is not perfect however, as @origin can return only a > single node (in fact, I wonder whether this should be changed in > XForms 1.2 - I just made a proposal to that effect as this is the > second day in a row where I hit the requirement of copying multiple > nodes with xforms:insert). > > As workarounds, I see without thinking too much: > > o Copying the root element returned by xxforms:call-xpl() into a > temporary instance, and then using xforms:insert/@while to copy all > the child elements to the destination instance > > o Using a submission with replace="instance" > > -Erik > > Alexander Zatko wrote: >> I have a need to generate a nodeset dynamically in my XForms >> instance based on xforms-value-changed event triggered when user >> selects an entry in a select1 drop-down. Can I use something like >> this: >> <xforms:bind >> nodeset="instance('pomocna')//systemy" >> calculate="xxforms:call-xpl >> ( >> 'oxf:/csp/users/edit_user/nacitaj- >> systemy.xpl', >> 'data', >> instance('main-instance')//zoznamy/ >> role/@selected, >> 'data' >> )"/> >> According to the XForms spec the expression in the "calculate" >> attribute should produce a value whereas the xxforms:call-xpl >> function will produce a nodeset. The xxforms:call-xpl function >> executes a db query which returns a nodest that I want to insert >> into the "instance('pomocna')//systemy" nodeset as a child of the >> "systemy" node. >> Possibly there is an alternative way to achieve my goal. >> A. >> --------------------------------------------------------------------- >> --- >> -- >> You receive this message as a subscriber of the ops- >> [hidden email] mailing list. >> To unsubscribe: mailto:[hidden email] >> For general help: mailto:[hidden email]?subject=help >> ObjectWeb mailing lists service home page: http:// >> www.objectweb.org/wws > > > -- > Orbeon - XForms Everywhere: > http://www.orbeon.com/blog/ > > > -- > You receive this message as a subscriber of the ops- > [hidden email] mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > ObjectWeb mailing lists service home page: http://www.objectweb.org/ > wws -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Administrator
|
With something like this:
<xforms:insert nodeset="instance('dest')" origin="xxforms:call-xpl(...)"/> -Erik Alexander Zatko wrote: > Erik, how would I copy the root returned by the xxforms:call-xpl() > function (as in the first option you proposed)? > > A. > > > On Oct 19, 2006, at 3:25 PM, Erik Bruchez wrote: > >> Alex, >> >> Yes, @calculate always returns a string. There is just no way to >> change that. >> >> Instead of xforms:bind/@calculate, you can use xforms:insert/@origin. >> You have to figure out an appropriate time to run that action, and >> then your @origin attribute can call xxforms:call-xpl(). This is not >> perfect however, as @origin can return only a single node (in fact, I >> wonder whether this should be changed in XForms 1.2 - I just made a >> proposal to that effect as this is the second day in a row where I hit >> the requirement of copying multiple nodes with xforms:insert). >> >> As workarounds, I see without thinking too much: >> >> o Copying the root element returned by xxforms:call-xpl() into a >> temporary instance, and then using xforms:insert/@while to copy all >> the child elements to the destination instance >> >> o Using a submission with replace="instance" >> >> -Erik >> >> Alexander Zatko wrote: >>> I have a need to generate a nodeset dynamically in my XForms instance >>> based on xforms-value-changed event triggered when user selects an >>> entry in a select1 drop-down. Can I use something like this: >>> <xforms:bind >>> nodeset="instance('pomocna')//systemy" >>> calculate="xxforms:call-xpl >>> ( >>> >>> 'oxf:/csp/users/edit_user/nacitaj-systemy.xpl', >>> 'data', >>> >>> instance('main-instance')//zoznamy/role/@selected, >>> 'data' >>> )"/> >>> According to the XForms spec the expression in the "calculate" >>> attribute should produce a value whereas the xxforms:call-xpl >>> function will produce a nodeset. The xxforms:call-xpl function >>> executes a db query which returns a nodest that I want to insert into >>> the "instance('pomocna')//systemy" nodeset as a child of the >>> "systemy" node. >>> Possibly there is an alternative way to achieve my goal. >>> A. >>> ------------------------------------------------------------------------ >>> -- >>> You receive this message as a subscriber of the >>> [hidden email] mailing list. >>> To unsubscribe: mailto:[hidden email] >>> For general help: mailto:[hidden email]?subject=help >>> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws >> >> >> --Orbeon - XForms Everywhere: >> http://www.orbeon.com/blog/ >> >> >> -- >> You receive this message as a subscriber of the >> [hidden email] mailing list. >> To unsubscribe: mailto:[hidden email] >> For general help: mailto:[hidden email]?subject=help >> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws > > > > ------------------------------------------------------------------------ > > > -- > You receive this message as a subscriber of the [hidden email] mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > ObjectWeb mailing lists service home page: http://www.objectweb.org/wws -- Orbeon - XForms Everywhere: http://www.orbeon.com/blog/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Erik,
Originally you wrote: >>> This is not perfect however, as @origin can return only a single >>> node I (believe) I verified that claim myself by testing, and only the root node of the nodeset returned by the xxforms:call-xpl() function was inserted by the xforms:insert. So I do not understand how would I copy the complete nodeset returned by the xxforms:call-xpl() when used as a value of the xforms:insert/ @origin attribute as you are advising me now. I also tested the replace="instance" approach and managed to have the instance submitted and updated (I can see this by looking at the log) by the same xpl that in my previous tests I had called by the xxforms:call-xpl() function, but the instance does not seem to get replaced. Is there any trick to the replace="instance" method? Here is my submission element: <xforms:submission id="akt-sys" ref="/" action="/users/akt-systes" method="post" replace="instance"/> In my XPL I have one input named "instance" and one output named "data". The view doc is XSL-generated. The submission in the view is invoked by this code: <xforms:select1... > <xforms:itemset nodeset="...."> <xforms:label ref="."/> <xforms:copy ref="."/> </xforms:itemset> <xforms:action ev:event="xforms-value-changed"> <xforms:setvalue ref="instance('main-instance')// action">update-sys</xforms:setvalue> <xforms:send submission="update-sys"/> </xforms:action> </xforms:select1> Thank you for your help A. On Oct 19, 2006, at 8:11 PM, Erik Bruchez wrote: > With something like this: > > <xforms:insert nodeset="instance('dest')" > origin="xxforms:call-xpl(...)"/> > > -Erik > > Alexander Zatko wrote: >> Erik, how would I copy the root returned by the xxforms:call-xpl() >> function (as in the first option you proposed)? >> A. >> On Oct 19, 2006, at 3:25 PM, Erik Bruchez wrote: >>> Alex, >>> >>> Yes, @calculate always returns a string. There is just no way to >>> change that. >>> >>> Instead of xforms:bind/@calculate, you can use xforms:insert/ >>> @origin. You have to figure out an appropriate time to run that >>> action, and then your @origin attribute can call xxforms:call-xpl >>> (). This is not perfect however, as @origin can return only a >>> single node (in fact, I wonder whether this should be changed in >>> XForms 1.2 - I just made a proposal to that effect as this is the >>> second day in a row where I hit the requirement of copying >>> multiple nodes with xforms:insert). >>> >>> As workarounds, I see without thinking too much: >>> >>> o Copying the root element returned by xxforms:call-xpl() into a >>> temporary instance, and then using xforms:insert/@while to copy >>> all the child elements to the destination instance >>> >>> o Using a submission with replace="instance" >>> >>> -Erik >>> >>> Alexander Zatko wrote: >>>> I have a need to generate a nodeset dynamically in my XForms >>>> instance based on xforms-value-changed event triggered when user >>>> selects an entry in a select1 drop-down. Can I use something >>>> like this: >>>> <xforms:bind >>>> nodeset="instance('pomocna')//systemy" >>>> calculate="xxforms:call-xpl >>>> ( >>>> 'oxf:/csp/users/edit_user/ >>>> nacitaj-systemy.xpl', >>>> 'data', >>>> instance('main-instance')// >>>> zoznamy/role/@selected, >>>> 'data' >>>> )"/> >>>> According to the XForms spec the expression in the "calculate" >>>> attribute should produce a value whereas the xxforms:call-xpl >>>> function will produce a nodeset. The xxforms:call-xpl function >>>> executes a db query which returns a nodest that I want to insert >>>> into the "instance('pomocna')//systemy" nodeset as a child of >>>> the "systemy" node. >>>> Possibly there is an alternative way to achieve my goal. >>>> A. >>>> ------------------------------------------------------------------- >>>> ----- >>>> -- >>>> You receive this message as a subscriber of the ops- >>>> [hidden email] mailing list. >>>> To unsubscribe: mailto:[hidden email] >>>> For general help: mailto:[hidden email]?subject=help >>>> ObjectWeb mailing lists service home page: http:// >>>> www.objectweb.org/wws >>> >>> >>> --Orbeon - XForms Everywhere: >>> http://www.orbeon.com/blog/ >>> >>> >>> -- >>> You receive this message as a subscriber of the ops- >>> [hidden email] mailing list. >>> To unsubscribe: mailto:[hidden email] >>> For general help: mailto:[hidden email]?subject=help >>> ObjectWeb mailing lists service home page: http:// >>> www.objectweb.org/wws >> --------------------------------------------------------------------- >> --- >> -- >> You receive this message as a subscriber of the ops- >> [hidden email] mailing list. >> To unsubscribe: mailto:[hidden email] >> For general help: mailto:[hidden email]?subject=help >> ObjectWeb mailing lists service home page: http:// >> www.objectweb.org/wws > > > -- > Orbeon - XForms Everywhere: > http://www.orbeon.com/blog/ > > > -- > You receive this message as a subscriber of the ops- > [hidden email] mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > ObjectWeb mailing lists service home page: http://www.objectweb.org/ > wws -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Administrator
|
Alex,
> I (believe) I verified that claim myself by testing, and only the > root node of the nodeset returned by the xxforms:call-xpl() function > was inserted by the xforms:insert. Correct. > So I do not understand how would I copy the complete nodeset returned by > the xxforms:call-xpl() when used as a value of the xforms:insert/@origin > attribute as you are advising me now. First step is to copy the result into a new instance: <xforms:instance id="dest"> <empty/> </xforms:instance> <xforms:insert nodeset="instance('dest')" origin="xxforms:call-xpl(...)"/> Then move over all the child elements of the root element of that instance to where you want to put them, using something like: <xforms:action while="instance("dest")/*"> <xforms:insert context="instance('wherever')" nodeset="*" origin="instance("dest")/*[1]"/> <xforms:delete nodeset="instance("dest")/*[1]"/> </xforms:action> > I also tested the replace="instance" approach and managed to have the > instance submitted and updated (I can see this by looking at the log) by > the same xpl that in my previous tests I had called by the > xxforms:call-xpl() function, but the instance does not seem to get > replaced. Is there any trick to the replace="instance" method? If the submission succeeded, then the instance should be replaced. Be sure to enabled XForms logging in log4j.xml to see what's happening there. -Erik -- Orbeon - XForms Everywhere: http://www.orbeon.com/blog/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Thanks Erik,
The code below works fine. A. On Oct 20, 2006, at 3:29 PM, Erik Bruchez wrote: > Alex, > > > I (believe) I verified that claim myself by testing, and only the > > root node of the nodeset returned by the xxforms:call-xpl() function > > was inserted by the xforms:insert. > > Correct. > > > So I do not understand how would I copy the complete nodeset > returned by > > the xxforms:call-xpl() when used as a value of the xforms:insert/ > @origin > > attribute as you are advising me now. > > First step is to copy the result into a new instance: > > <xforms:instance id="dest"> > <empty/> > </xforms:instance> > > <xforms:insert nodeset="instance('dest')" > origin="xxforms:call-xpl(...)"/> > > Then move over all the child elements of the root element of that > instance to where you want to put them, using something like: > > <xforms:action while="instance("dest")/*"> > <xforms:insert context="instance('wherever')" nodeset="*" > origin="instance("dest")/*[1]"/> > <xforms:delete nodeset="instance("dest")/*[1]"/> > </xforms:action> > > > I also tested the replace="instance" approach and managed to have > the > > instance submitted and updated (I can see this by looking at the > log) by > > the same xpl that in my previous tests I had called by the > > xxforms:call-xpl() function, but the instance does not seem to get > > replaced. Is there any trick to the replace="instance" method? > > If the submission succeeded, then the instance should be replaced. Be > sure to enabled XForms logging in log4j.xml to see what's happening > there. > > -Erik > > -- > Orbeon - XForms Everywhere: > http://www.orbeon.com/blog/ > > > > -- > You receive this message as a subscriber of the ops- > [hidden email] mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > ObjectWeb mailing lists service home page: http://www.objectweb.org/ > wws -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
In reply to this post by Alexander Žaťko
Alexander,
there might be an easier way to do this. If I understand you correctly, you want to do asynchronous updates to the page (i.e. without reloading the whole page) when the user selects a value from a drop down box. If so, there is a built-in method in XForms for doing just this: 1. Start by adding the attribute 'replace="instance"' to your submission. <xforms:submission id="test-expression-submission" ref="instance('test-expression')" method="post" action="/query/nexttermtoken" replace="instance"/> 2. Then add the attribute 'incremental="true"' to your XForms control <xforms:select1 ref="instance('test-expression')/aspic:expression" selection="open" incremental="true" appearance="xxforms:autocomplete"> <xforms:itemset nodeset="instance('knowledgebase')/aspic:predictive/aspic:name"> <xforms:label ref="."/> <xforms:value ref="."/> </xforms:itemset> <xforms:label ref="instance('resources-instance')/aspic:testexpression"/> <xforms:action ev:event="xforms-value-changed"> <xforms:send submission="test-expression-submission"/> </xforms:action> </xforms:select1> 3. Declare your web service in pageflow.xml. This service will return you the updated instance data when calling "test-expression-submission". Note how the "view" attribute points to your xpl. <page path-info="/query/nexttermtoken" id="query.nexttermtoken" view="oxf:/knowledgebase/service/nextTermToken.xpl"/> 4. Here is my data generating XPL, as an example: <p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:oxf="http://www.orbeon.com/oxf/processors " xmlns:aspic="http://www.cruk.com/aspic/editor/v1"> <p:param name="instance" type="input" debug="******************INPUT***************"/> <p:param name="data" type="output" debug="******************OUTPUT***************"/> <p:processor name="oxf:java"> <p:input name="config"> <config sourcepath="oxf:/java" class="org.cruk.aspic.editor.api.orbeon.NextTermToken"/> </p:input> <p:input name="data" href="#instance"/> <p:output name="data" ref="data"/> </p:processor> </p:config> 5. Word of advice: Try to shape and transform your instance data in the xpl - > "insert into the "instance('pomocna')//systemy" nodeset as a child of the 'systemy' node" might be more easily achieved if done in the xpl. Hope this helps and was to the point. Sincerely, Henrik Pettersen On 10/19/06,
Alexander Zatko <[hidden email]> wrote:
I have a need to generate a nodeset dynamically in my XForms instance -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Free forum by Nabble | Edit this page |