I would like use one trigger to execute one of event handlers depend on some value. For example, <xf:model> <xf:instance id="data"> <root xmlns=""> <data /> <handler /> </root> </xf:instance> <xf:action ev:observer="trigger" ev:event="DOMActivate"> <xf:setvalue ref="./data" value="'nothing'" /> </xf:action> <xf:action ev:observer="trigger" ev:event="DOMActivate"> <xf:setvalue ref="./data" value="'something'" /> </xf:action> </xf:model> <xf:input ref="./data"> <xf:label>input something:</xf:label> </xf:input> <xf:trigger id="trigger"> <xf:label>assign value</xf:label> </xf:trigger> I have two event handlers. I would like to determine which event handler be executed depend on handler's value. If handler's value is "first", assign "nothing" to data. If handler's value is "second", assign "something" to data. How to accomplish it? thanks for any suggestion, Jack -- 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 |
Jack,
you could use javascript to switch between different setvalues depending on any input: <xf:action ev:observer="trigger" ev:event="DOMActivate"> <xxforms:script> var value = ORBEON.xforms.Document.getValue("id_of_input_element"); var output; switch (value) { case "first": output='nothing'; break; case "second": output='something'; break; default: output='whatever'; break; } ORBEON.xforms.Document.setValue("id_of_output_element", output); </xxforms:script> </xf:action> But if there are only some valid values to select, a xf:select1 would be the preferable solution, i think. Then you don't need any triggers or setvalue commands. HTH florian -- 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 |
Thanks for Your suggestion.
The value which I set is from instance get from database. I can't get the value from script. Or simply how to know which event handler should be activated? I have used "dispatch" to dispatch event to all event handlers and use "cancelable" to cancel the wrong event handler, but it doesn't work. Although it works, how do I cancel event dynamically(depend some value)? Jack -- 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 |
Jack,
> The value which I set is from instance get from database. > I can't get the value from script. if you have the value in an instance, you can get it :-) - just add a xforms:input with style="display:none;". This input control won't be displayed, but you can reference it to get/set the value using javascript. > Or simply how to know which event handler should be activated? i didn't find a way to conditionally activate/decativate a handler. So i think you will have to put the logic what to insert inside the handler. HTH florian -- 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
|
In reply to this post by tayjack-2
On Jan 11, 2009, at 4:11 AM, tayjack wrote:
> I have two event handlers. Do you need two event handlers? Would it be possible to simply write: <xforms:setvalue ref="data" value="if (../handler = 'first') then 'nothing' else 'something'"/> If you really need two handlers, you can also put that condition in an "if" attribute, for instance: <xforms:action if="../handler = 'first'" ev:observer="trigger" ev:event="DOMActivate">. Alex -- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ -- 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 |
Thanks you, Alex your suggestion just meet my need. All suggestions replied are helpful. thanks everyone Jack -- 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
|
Jack,
On Jan 13, 2009, at 5:54 PM, tayjack wrote: > your suggestion just meet my need. > > All suggestions replied are helpful. Excellent! Thanks for the update. Alex -- Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise Orbeon's Blog: http://www.orbeon.com/blog/ Personal Blog: http://avernet.blogspot.com/ -- 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 |