Is it possible to dynamically add a bind element to the model?
I have a form where users can add another field to it, and I want them to be able to specify the xs:type of the field. I know I can submit the form, and then reload it with the additonal bind element added to the model, but I was really hoping that I wouldn't have to make that round trip call. and That I could use some sort of xforms:insert or something. This seems like something that has to have been tackled in formbuilder, so I figure there must be a way. thanks for the help. -- 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
|
Jeremiah,
It's not possible to add a new xforms:bind, but if you already had binds with all the types in your form, you could play with the @nodeset attribute, e.g.: <xforms:bind type="xs:integer" nodeset="...dynamically point to nodes that must be integers..."/> -Erik On Sat, Jan 2, 2010 at 11:21 AM, Jeremiah Jahn <[hidden email]> wrote: > Is it possible to dynamically add a bind element to the model? > > I have a form where users can add another field to it, and I want them to be able to specify the xs:type of the field. I know I can submit the form, and then reload it with the additonal bind element added to the model, but I was really hoping that I wouldn't have to make that round trip call. and That I could use some sort of xforms:insert or something. This seems like something that has to have been tackled in formbuilder, so I figure there must be a way. > > thanks for the help. > > -- > 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 |
Is there an example of something like that laying around?
and is there any way to modify the nodeset attr from within the form. I didnt think so, but the phrasing of your statement gives me hope that there is. My problem is that I don't know what the data structure in the form is element names and paths included. Only the instance name. And users can dynamically add an element of any name and type at any point. making it a little funky. On Jan 27, 2010, at 10:40 AM, Erik Bruchez wrote: > Jeremiah, > > It's not possible to add a new xforms:bind, but if you already had > binds with all the types in your form, you could play with the > @nodeset attribute, e.g.: > > <xforms:bind type="xs:integer" nodeset="...dynamically point to nodes > that must be integers..."/> > > -Erik > > On Sat, Jan 2, 2010 at 11:21 AM, Jeremiah Jahn <[hidden email]> wrote: >> Is it possible to dynamically add a bind element to the model? >> >> I have a form where users can add another field to it, and I want them to be able to specify the xs:type of the field. I know I can submit the form, and then reload it with the additonal bind element added to the model, but I was really hoping that I wouldn't have to make that round trip call. and That I could use some sort of xforms:insert or something. This seems like something that has to have been tackled in formbuilder, so I figure there must be a way. >> >> thanks for the help. >> >> -- >> 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 -- 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 |
In reply to this post by Erik Bruchez
I tried this, and although it works for the initial view of the page, I'm obviously missing something to get it to recalculate or something after I change the type. Do I need to dispatch something? because the xpath is defiantly working. Like I said, it just seems to only work on the initial load, but not after any changes. <xforms:bind nodeset="for $currentItem in instance('data')/descendant-or-self::*/@* return $currentItem[$currentItem/name() = instance('types')/types/type[@typeID = $currentItem/../name()]/type[binding/@type = 'xs:boolean']/@typeID]" type="xs:boolean" /> On Jan 27, 2010, at 10:40 AM, Erik Bruchez wrote:
-- 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 |
Jeremiah,
Have you tried the calculate= attribute? That is executed when dependent nodesets change. --Hank On Feb 7, 2010, at 6:48 PM, Jeremiah Jahn wrote:
Hank Ratzesberger NEES@UCSB Institute for Crustal Studies, University of California, Santa Barbara 805-893-8042 -- 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 |
guess I'm not quite sure how that would help, having never used it for anything before.
I'll flush out my example a little bit more: <xforms:bind nodeset="for $currentItem in instance('data')/descendant-or-self::*/@* return $currentItem[$currentItem/name() = instance('types')/types/type[@typeID = $currentItem/../name()]/type[binding/@type = 'xs:string']/@typeID]" type="xs:string" /> <xforms:bind nodeset="for $currentItem in instance('data')/descendant-or-self::*/@* return $currentItem[$currentItem/name() = instance('types')/types/type[@typeID = $currentItem/../name()]/type[binding/@type = 'xs:date']/@typeID]" type="xs:date" /> <xforms:bind nodeset="for $currentItem in instance('data')/descendant-or-self::*/@* return $currentItem[$currentItem/name() = instance('types')/types/type[@typeID = $currentItem/../name()]/type[binding/@type = 'xs:int']/@typeID]" type="xs:int" /> <xforms:bind nodeset="for $currentItem in instance('data')/descendant-or-self::*/@* return $currentItem[$currentItem/name() = instance('types')/types/type[@typeID = $currentItem/../name()]/type[binding/@type = 'xs:boolean']/@typeID]" type="xs:boolean" /> There is a select1 which sets my type/binding/@type to 'xs:whatever' string, date, boolean etc. The problem is that after choosing a different type for an input, the input is still set to the original value. For example if it was a boolean, and i choose a :xs:string instead, the input stays as a date input and not a text input, or int or whatever I choose. Its as if the above, and there are many more, bind statements are not being reevaluated when the nodeset changes. i was hoping there was an event I could dispatch that would cause it to re-whatever. The calculate attribute doesn't seem to be what I need, as I'm not changing the value, but the type. On Feb 8, 2010, at 9:41 AM, Hank Ratzesberger wrote:
-- 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 |
Hi Jeremiah,
Thanks, that is a bit more clear now. XForms provides for adding and deleting nodes where a template for the node exists, but in your case it is all specified at runtime by the user, so I don't immediately see how you can build such a nodeset at runtime using xforms:insert . What if the nodeset you were binding to were replaced? Then perhaps the binding part would re-run. You could submit to an xpl/xslt service the values for the types the user has selected, and it would return the nodeset rewritten with the new types. I can only assume that the same steps as the model construct occur when an instance is replaced, including re-evaluating the bindings. Of course, there is a question about how to do the submit. I suppose you don't want to require the user to click a trigger such as "Refresh" or "Confirm changes", but that would make the test quicker to write. HTH, Hank On Feb 8, 2010, at 1:45 PM, Jeremiah Jahn wrote:
Hank Ratzesberger NEES@UCSB Institute for Crustal Studies, University of California, Santa Barbara 805-893-8042 -- 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 |
That's an interesting thought. The user does have to switch to a different tab before seeing the effect of their changes. That might be a good time to submit & replace things. I was really hoping to avoid that, but it could be made somewhat transparent.
On Feb 8, 2010, at 4:46 PM, Hank Ratzesberger wrote:
It's not pretty, but it works. and using a lot of xxforms:element helps.
so of the instances I have that are relevant. your suggesting that I mod the types instance the way I am. Then once the user has indicated that they are done in some way, replace the data instance with a copy of itself? It's really too bad there isn't a simple event to fire that would do that, but like I said above, they have to switch tabs, so might as well do it then.
-- 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 |
In reply to this post by HankRatz
yeah! after much messing around with red herrings requiring valid data (who knew) If I replace my type instance or my data instance with a submission, that basically echos every thing w/o saving it, it will cause the controls to switch and the binds to revalidate everything. Very cool thanks for the suggestions. I did for the heck of it try add of the refresh and similar events to no avail.
On Feb 8, 2010, at 4:46 PM, Hank Ratzesberger wrote:
-- 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 |
Glad to hear that. Very best. On Feb 10, 2010, at 6:06 PM, Jeremiah Jahn wrote:
Hank Ratzesberger NEES@UCSB Institute for Crustal Studies, University of California, Santa Barbara 805-893-8042 -- 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 |