You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ben Anderson <be...@gmail.com> on 2005/04/05 21:21:47 UTC
[Forms] broadcastEvent
Hi,
I have one text field which, once changed, will populate 2 drop down
lists. However, the 2nd drop down is dependent on the 1st drop down.
So, I have this in my text field's definition
<fd:on-value-changed>
<javascript>
...
// this populates the 1st drop down
raIdWidget.setSelectionList("cocoon:/selection-lists/raIds?raSearch=" + value)
// I'd like to get the first value out of this select list. Is this possible?
// I tried the following line, but it doesn't work... it's still the old value.
// var raId = raIdWidget.value
// Because now I'd like to trigger an event
raIdWidget.broadcastEvent(
new Packages.org.apache.cocoon.forms.event.ValueChangedEvent(
raIdWidget,
raIdOldValue,
raId));
...
and then in the javascript for the value changed event of the 1st
drop-down, I populate the 2nd drop down.
This seems to all fit together except for the above mentioned gap. Is
there a way to get a value out of the selection list, even though it
isn't explicitly set?
Thanks,
Ben
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [Forms] broadcastEvent
Posted by Ben Anderson <be...@gmail.com>.
> You can also have a look at the
> org.apache.cocoon.components.flow.util.PipelineUtil class. It's a
> generalization of cocoon.processPipelineTo not only for streams, but
> also DOM and SAX handlers.
This is working nicely. Thanks for the help, Sylvain.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [Forms] broadcastEvent
Posted by Sylvain Wallez <sy...@apache.org>.
Ben Anderson wrote:
>ok, I won't use broadcastEvent()...
>
>Is there a way to specify a default value for the selection-list
>throught the pipeline specified? For instance my pipeline could
>return something like:
>
><fd:selection-list default="1">
> <fd:item value="1">
> <fd:label>foo</fd:label>
> </fd:item>
> <fd:item value="2">
> <fd:label>bar</fd:label>
> </fd:item>
></fd:selection-list>
>
>so now when I run this code:
> someWidget.setSelectionList("cocoon:/selection-lists/some/pipe?raSearch="
>+ value);
> var raId = someWidget.getValue();
>
>so now raId contains 1. That would certainly help me out.
>
>
Unfortunately, that isn't possible with an URL-defined selection list.
Such lists are generated only when the form is displayed, i.e. in the
view pipeline. There are other selection list implementations that rely
on some existing data structure that could allow this (although not
currently), but not the SAX stream based list defined by an URL.
>I guess I'll try using processPipelineTo here. I've heard people
>mention on the list before that rhino has some inherent xml processing
>abilities. Can anyone point me to documentation for this?
>
>
You can also have a look at the
org.apache.cocoon.components.flow.util.PipelineUtil class. It's a
generalization of cocoon.processPipelineTo not only for streams, but
also DOM and SAX handlers.
Sylvain
--
Sylvain Wallez Anyware Technologies
http://apache.org/~sylvain http://anyware-tech.com
Apache Software Foundation Member Research & Technology Director
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [Forms] broadcastEvent
Posted by Ben Anderson <be...@gmail.com>.
ok, I won't use broadcastEvent()...
Is there a way to specify a default value for the selection-list
throught the pipeline specified? For instance my pipeline could
return something like:
<fd:selection-list default="1">
<fd:item value="1">
<fd:label>foo</fd:label>
</fd:item>
<fd:item value="2">
<fd:label>bar</fd:label>
</fd:item>
</fd:selection-list>
so now when I run this code:
someWidget.setSelectionList("cocoon:/selection-lists/some/pipe?raSearch="
+ value);
var raId = someWidget.getValue();
so now raId contains 1. That would certainly help me out.
I guess I'll try using processPipelineTo here. I've heard people
mention on the list before that rhino has some inherent xml processing
abilities. Can anyone point me to documentation for this?
Thanks,
Ben
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: [Forms] broadcastEvent
Posted by Sylvain Wallez <sy...@apache.org>.
Ben Anderson wrote:
>Hi,
>I have one text field which, once changed, will populate 2 drop down
>lists. However, the 2nd drop down is dependent on the 1st drop down.
>
>So, I have this in my text field's definition
>
><fd:on-value-changed>
> <javascript>
>...
>// this populates the 1st drop down
>raIdWidget.setSelectionList("cocoon:/selection-lists/raIds?raSearch=" + value)
>// I'd like to get the first value out of this select list. Is this possible?
>// I tried the following line, but it doesn't work... it's still the old value.
>// var raId = raIdWidget.value
>// Because now I'd like to trigger an event
>raIdWidget.broadcastEvent(
> new Packages.org.apache.cocoon.forms.event.ValueChangedEvent(
> raIdWidget,
> raIdOldValue,
> raId));
>...
>
>
broadcastEvent is really an internal method that should be used only by
CForms itself, and you should not use it in your application code.
>and then in the javascript for the value changed event of the 1st
>drop-down, I populate the 2nd drop down.
>
>This seems to all fit together except for the above mentioned gap. Is
>there a way to get a value out of the selection list, even though it
>isn't explicitly set?
>
>
You cannot get a value out of the selection list, except by fetching a
value from the SAX stream it produces. However, you can explicitely set
the value of the widget whose selection list has changed.
What's usually done in such cases is to set the value of the widget
whose list has changed to null. Have a look at the carselector in the
forms samples that examplifies this.
Sylvain
--
Sylvain Wallez Anyware Technologies
http://apache.org/~sylvain http://anyware-tech.com
Apache Software Foundation Member Research & Technology Director
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org