How do you call a
JavaScript function from within a <xforms:select/> on the
"xforms-value-changed" event? I've attached a sample view.xhtml where I get the
below error when I try to run it:
XML Parsing Error:
no element found
Location: http://localhost:8080/orbeon/xforms-sr/view.xhtml?order-id=256 Line Number 1, Column 1: What I need to be
able to do is create a comma separated list of item labels that were chosen in
the <select/> control and insert it into the select
ref="serverOperatindSystem" elements label attribute. Any ideas on the best way
to do this (if not via JavaScript) would be greatly
appreciated.
Thanks.
Martin
Schwartzman
-- 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 OW2 mailing lists service home page: http://www.ow2.org/wws view.xhtml (17K) Download Attachment |
Administrator
|
Martin, So compared to what the xforms:select does out of the box, you need the list of selected values to be coma separated, rather than space separated as the xforms:select does "by default"? Alex
-- 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 OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Alex,
Not exactly. We need to populate a GUI control with what that user chose from the xforms:select (in a Flex app from the xforms generated XML). We want to display the <label> values. For example, Windows, Unix not windows, unix. So somehow I need to iterate through the list of selected values and capture the labels, comma separate the labels and setvalue them into the @label attribute of the serverOperatingSystem element on "xforms-value-changed xforms-enabled". This is my guess. If I'm doing this totally wrong please tell me. This seems to me like something that should be easy but I'm just not seeing the easy way. <xforms:instance id="addServer-serverOperatingSystem-instance"> <data> <row> <label>Windows</label> <value>windows</value> </row> <row> <label>Unix</label> <value>unix</value> </row> <row> <label>Linux</label> <value>linux</value> </row> </data> </xforms:instance> This captures the label for a single xforms:select1 list but does not work for a multi xforms:select list. <xforms:select1 ref="serverOperatingSystem"> <other stuff needed for select1> <xforms:action ev:event="xforms-value-changed xforms-enabled"> <xxforms:variable name="theValue" select="xxforms:instance('addServers-instance')/addServer/serverOperatin gSystem"/> <xforms:setvalue ref="xxforms:instance('addServers-instance')/addServer/serverOperatingSy stem/@label" value="xxforms:instance('addServer-serverOperatingSystem-instance')/row[ contains(.//value, $theValue)]/label"/> <xforms:setvalue ref="xxforms:instance('addServers-instance')/addServer/serverOperatingSy stem" value="xxforms:instance('addServer-serverOperatingSystem-instance')/row[ contains(.//value, $theValue)]/value"/> </xforms:action> </xforms:select1> p.s. this does not work if the data for the list is retrieved from on .xpl query to our MS SQL Server DB. It only works when the items come from an xforms:instance. This is a problem I've described (and need to solve) in the past few days. Thanks. Martin ________________________________ From: Alessandro Vernet [mailto:[hidden email]] Sent: Wednesday, December 16, 2009 4:57 PM To: [hidden email] Subject: [ops-users] Re: Martin, So compared to what the xforms:select does out of the box, you need the list of selected values to be coma separated, rather than space separated as the xforms:select does "by default"? Alex On Dec 16, 2009, at 10:27 AM, "Schwartzman, Martin" <[hidden email]> wrote: How do you call a JavaScript function from within a <xforms:select/> on the "xforms-value-changed" event? I've attached a sample view.xhtml where I get the below error when I try to run it: XML Parsing Error: no element found Location: <http://localhost:8080/orbeon/xforms-sr/view.xhtml?order-id=256> http://localhost:8080/orbeon/xforms-sr/view.xhtml?order-id=256 Line Number 1, Column 1: What I need to be able to do is create a comma separated list of item labels that were chosen in the <select/> control and insert it into the select ref="serverOperatindSystem" elements label attribute. Any ideas on the best way to do this (if not via JavaScript) would be greatly appreciated. Thanks. Martin Schwartzman <view.xhtml> -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: <mailto:[hidden email]> mailto:[hidden email] For general help: <mailto:[hidden email]?subject=help> mailto:[hidden email]?subject=help OW2 mailing lists service home page: <http://www.ow2.org/wws> http://www.ow2.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 OW2 mailing lists service home page: http://www.ow2.org/wws |
Administrator
|
Martin,
OK, let me see if I understood you this time. An xforms:bind should do the trick here. I created a stand-alone example that shows this in action: http://pastie.org/746654. As far as having the data (OS list) statically or coming in through an XPL call, this really shouldn't make a difference, as long as it gets into an instance. You'll let me know how this works for you. Alex On Dec 16, 2009, at 4:24 PM, "Schwartzman, Martin" <[hidden email] > wrote: > Alex, > > Not exactly. We need to populate a GUI control with what that user > chose > from the xforms:select (in a Flex app from the xforms generated > XML). We > want to display the <label> values. For example, Windows, Unix not > windows, unix. So somehow I need to iterate through the list of > selected > values and capture the labels, comma separate the labels and setvalue > them into the @label attribute of the serverOperatingSystem element on > "xforms-value-changed xforms-enabled". This is my guess. If I'm doing > this totally wrong please tell me. This seems to me like something > that > should be easy but I'm just not seeing the easy way. > > <xforms:instance id="addServer-serverOperatingSystem-instance"> > <data> > <row> > <label>Windows</label> > <value>windows</value> > </row> > <row> > <label>Unix</label> > <value>unix</value> > </row> > <row> > <label>Linux</label> > <value>linux</value> > </row> > </data> > </xforms:instance> > > > This captures the label for a single xforms:select1 list but does not > work for a multi xforms:select list. > > <xforms:select1 ref="serverOperatingSystem"> > > <other stuff needed for select1> > > <xforms:action ev:event="xforms-value-changed xforms-enabled"> > <xxforms:variable name="theValue" > select="xxforms:instance('addServers-instance')/addServer/ > serverOperatin > gSystem"/> > <xforms:setvalue > ref="xxforms:instance('addServers-instance')/addServer/ > serverOperatingSy > stem/@label" > value="xxforms:instance('addServer-serverOperatingSystem-instance')/ > row[ > contains(.//value, $theValue)]/label"/> > <xforms:setvalue > ref="xxforms:instance('addServers-instance')/addServer/ > serverOperatingSy > stem" > value="xxforms:instance('addServer-serverOperatingSystem-instance')/ > row[ > contains(.//value, $theValue)]/value"/> > </xforms:action> > > </xforms:select1> > > p.s. this does not work if the data for the list is retrieved from on > .xpl query to our MS SQL Server DB. It only works when the items come > from an xforms:instance. This is a problem I've described (and need to > solve) in the past few days. > > > Thanks. > > Martin > > > > ________________________________ > > From: Alessandro Vernet [mailto:[hidden email]] > Sent: Wednesday, December 16, 2009 4:57 PM > To: [hidden email] > Subject: [ops-users] Re: > > > Martin, > > So compared to what the xforms:select does out of the box, you need > the > list of selected values to be coma separated, rather than space > separated as the xforms:select does "by default"? > > Alex > > On Dec 16, 2009, at 10:27 AM, "Schwartzman, Martin" > <[hidden email]> wrote: > > > > How do you call a JavaScript function from within a > <xforms:select/> on the "xforms-value-changed" event? I've attached a > sample view.xhtml where I get the below error when I try to run it: > > XML Parsing Error: no element found > Location: > <http://localhost:8080/orbeon/xforms-sr/view.xhtml?order-id=256> > http://localhost:8080/orbeon/xforms-sr/view.xhtml?order-id=256 > Line Number 1, Column 1: > > What I need to be able to do is create a comma separated list of > item labels that were chosen in the <select/> control and insert it > into > the select ref="serverOperatindSystem" elements label attribute. Any > ideas on the best way to do this (if not via JavaScript) would be > greatly appreciated. > > > Thanks. > > Martin Schwartzman > > > <view.xhtml> > > > -- > You receive this message as a subscriber of the > [hidden email] mailing list. > To unsubscribe: <mailto:[hidden email]> > mailto:[hidden email] > For general help: <mailto:[hidden email]?subject=help> > mailto:[hidden email]?subject=help > OW2 mailing lists service home page: <http://www.ow2.org/wws> > http://www.ow2.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 > OW2 mailing lists service home page: http://www.ow2.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 OW2 mailing lists service home page: http://www.ow2.org/wws
--
Follow Orbeon on Twitter: @orbeon Follow me on Twitter: @avernet |
Alex,
The bind part did not work for me but the xpath expression did. Thank you. My last problem seems to be that data coming through an XPL is not making it into the instance before the "xforms-enabled" event is fired. Is there another event I can use or another technique? Note: the <xforms:select/> element below is inside a <xforms:repeat/> element. <xforms:select ref="serverOperatingSystem"> <xforms:label class="fieldLabel">Operating System:</xforms:label> <!-- valueListName parameter driven list (stored in db) --> <xforms:itemset nodeset="xxforms:instance('valueListLK-addFilesystem-serverOperatingSyst em-15-instance')/row" model="valueListLK-addFilesystem-serverOperatingSystem-15-model"> <xforms:label class="fieldLabel" ref="label"/> <xforms:value ref="value"/> </xforms:itemset> <xforms:action ev:event="xforms-value-changed"> <xxforms:variable name="theLabel" select="string-join(for $value in tokenize(xxforms:instance('addServers-instance')/addFilesystem[xxforms:i ndex('addFilesystem-repeat')]/serverOperatingSystem, '\s') return xxforms:instance('valueListLK-addFilesystem-serverOperatingSystem-15-ins tance')/row[value = $value]/label, ',')"/> <xforms:setvalue ref="xxforms:instance('addServers-instance')/addFilesystem[xxforms:index ('addFilesystem-repeat')]/serverOperatingSystem/@label" value="$theLabel"/> </xforms:action> <!-- persist initial dropdown values both label and value--> <xforms:action ev:event="xforms-enabled"> <!-- This should work but does not which seems to indicate that there is no value in the valueListLK-addFilesystem-serverOperatingSystem-15-instance at the time the "xforms-enabled" event is executed --> <xforms:setvalue ref="xxforms:instance('addServers-instance')/addFilesystem[xxforms:index ('addFilesystem-repeat')]/serverOperatingSystem" value="xxforms:instance('valueListLK-addFilesystem-serverOperatingSystem -15-instance')/row[1]/value"/> <xxforms:variable name="theLabel" select="string-join(for $value in tokenize(xxforms:instance('addServers-instance')/addFilesystem[xxforms:i ndex('addFilesystem-repeat')]/serverOperatingSystem, '\s') return xxforms:instance('valueListLK-addFilesystem-serverOperatingSystem-15-ins tance')/row[value = $value]/label, ',')"/> <xforms:setvalue ref="xxforms:instance('addServers-instance')/addFilesystem[xxforms:index ('addFilesystem-repeat')]/serverOperatingSystem/@label" value="$theLabel"/> </xforms:action> </xforms:select> Thanks. Martin -----Original Message----- From: Alessandro Vernet [mailto:[hidden email]] Sent: Wednesday, December 16, 2009 8:23 PM To: [hidden email] Subject: [ops-users] Re: RE: Re: Martin, OK, let me see if I understood you this time. An xforms:bind should do the trick here. I created a stand-alone example that shows this in action: http://pastie.org/746654. As far as having the data (OS list) statically or coming in through an XPL call, this really shouldn't make a difference, as long as it gets into an instance. You'll let me know how this works for you. Alex On Dec 16, 2009, at 4:24 PM, "Schwartzman, Martin" <[hidden email] > wrote: > Alex, > > Not exactly. We need to populate a GUI control with what that user > chose from the xforms:select (in a Flex app from the xforms generated > XML). We want to display the <label> values. For example, Windows, > Unix not windows, unix. So somehow I need to iterate through the list > of selected values and capture the labels, comma separate the labels > and setvalue them into the @label attribute of the > serverOperatingSystem element on "xforms-value-changed > xforms-enabled". This is my guess. If I'm doing this totally wrong > please tell me. This seems to me like something that should be easy > but I'm just not seeing the easy way. > > <xforms:instance id="addServer-serverOperatingSystem-instance"> > <data> > <row> > <label>Windows</label> > <value>windows</value> > </row> > <row> > <label>Unix</label> > <value>unix</value> > </row> > <row> > <label>Linux</label> > <value>linux</value> > </row> > </data> > </xforms:instance> > > > This captures the label for a single xforms:select1 list but does not > work for a multi xforms:select list. > > <xforms:select1 ref="serverOperatingSystem"> > > <other stuff needed for select1> > > <xforms:action ev:event="xforms-value-changed xforms-enabled"> > <xxforms:variable name="theValue" > select="xxforms:instance('addServers-instance')/addServer/ > serverOperatin > gSystem"/> > <xforms:setvalue > ref="xxforms:instance('addServers-instance')/addServer/ > serverOperatingSy > stem/@label" > value="xxforms:instance('addServer-serverOperatingSystem-instance')/ > row[ > contains(.//value, $theValue)]/label"/> <xforms:setvalue > ref="xxforms:instance('addServers-instance')/addServer/ > serverOperatingSy > stem" > value="xxforms:instance('addServer-serverOperatingSystem-instance')/ > row[ > contains(.//value, $theValue)]/value"/> </xforms:action> > > </xforms:select1> > > p.s. this does not work if the data for the list is retrieved from on > .xpl query to our MS SQL Server DB. It only works when the items come > from an xforms:instance. This is a problem I've described (and need to > solve) in the past few days. > > > Thanks. > > Martin > > > > ________________________________ > > From: Alessandro Vernet [mailto:[hidden email]] > Sent: Wednesday, December 16, 2009 4:57 PM > To: [hidden email] > Subject: [ops-users] Re: > > > Martin, > > So compared to what the xforms:select does out of the box, you need > the list of selected values to be coma separated, rather than space > separated as the xforms:select does "by default"? > > Alex > > On Dec 16, 2009, at 10:27 AM, "Schwartzman, Martin" > <[hidden email]> wrote: > > > > How do you call a JavaScript function from within a > <xforms:select/> on the "xforms-value-changed" event? I've attached a > sample view.xhtml where I get the below error when I try to run it: > > XML Parsing Error: no element found > Location: > <http://localhost:8080/orbeon/xforms-sr/view.xhtml?order-id=256> > http://localhost:8080/orbeon/xforms-sr/view.xhtml?order-id=256 > Line Number 1, Column 1: > > What I need to be able to do is create a comma separated list of > item labels that were chosen in the <select/> control and insert it > into the select ref="serverOperatindSystem" elements label attribute. > Any ideas on the best way to do this (if not via JavaScript) would be > greatly appreciated. > > > Thanks. > > Martin Schwartzman > > > <view.xhtml> > > > -- > You receive this message as a subscriber of the [hidden email] > mailing list. > To unsubscribe: <mailto:[hidden email]> > mailto:[hidden email] > For general help: <mailto:[hidden email]?subject=help> > mailto:[hidden email]?subject=help > OW2 mailing lists service home page: <http://www.ow2.org/wws> > http://www.ow2.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 > OW2 mailing lists service home page: http://www.ow2.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 OW2 mailing lists service home page: http://www.ow2.org/wws |
Free forum by Nabble | Edit this page |