cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul G. Joseph" <pjos...@gmail.com>
Subject Re: how to obtain selected values in a multi-value dropdown
Date Mon, 14 Oct 2013 13:45:24 GMT
Hi Robby,

Thanks for your email.  I wasn't able to get this to work...but was able 
to work around this problem as shown below.

       <fd:on-value-changed>
           <javascript>
               var value = event.source.getValue();
               var collection = new java.util.ArrayList();
                  for(var i=0; i&lt;value.length; i++) {
                    collection.add(value[i]);
                  }
         </javascript>
       </fd:on-value-changed>

Thanks again for your help.
Paul

On 10/14/2013 3:53 AM, Robby Pelssers wrote:
> >From the looks of it a org.apache.cocoon.forms.event.ValueChangedEvent has this interface
>
>
> Method Summary
>   Object getNewValue()
>
>   Object getOldValue()
>
>
> why don't you just try
>
> var newvalues = event.getNewValue();
>
> I'm assuming now that this is an array in the multiselect case.
>
> If that doesn't work... let me know.
>
> Robby
> Schrijf je nu alvast in voor het TFG Innovation Event 2013 op 30 oktober
>
> R?ntgenlaan 27 | 2719 DX Zoetermeer
> www.the-future-group.com
> +31 (0)79 - 363 2905
> http://twitter.com/futuregroup
>
> 06 15879926
> robby.pelssers@the-future-group.com
>
> ________________________________________
> Van: Paul G. Joseph [pjoseph@gmail.com]
> Verzonden: woensdag 9 oktober 2013 22:24
> To: users@cocoon.apache.org
> Onderwerp: how to obtain selected values in a multi-value dropdown
>
> Hi there,
>
> I am using Cocoon 2.1.11 and CForms/Javascript/Java in Tomcat.
>
> In a form (say myform.xml) I have two fields--both dropdowns.  One is
> multi-select, the other not.
>
> The multiselect field is as below:
>
> <fd:multivaluefield id="MULTI" required="false">
> <fd:datatype base="string"/>
> <fd:selection-list>
> <fd:item value="Cat"/>
> <fd:item value="Dog"/>
> <fd:item value="Mouse"/>
> </fd:selection-list>
>         <fd:on-value-changed>
>             <javascript>
>             debug("Came here 1");
>                 var value = event.source.value;
>             debug("value is: " + value);
>             </javascript>
>         </fd:on-value-changed>
> </fd:field>
>
> The other (no multi-select) is as follows:
>
> <fd:field id="SINGLE" required="false">
> <fd:datatype base="string"/>
> <fd:selection-list>
> <fd:item value="Lion"/>
> <fd:item value="Tiger"/>
> <fd:item value="Bear"/>
> </fd:selection-list>
>         <fd:on-value-changed>
>             <javascript>
>             debug("Came here 2");
>                 var value = event.source.value;
>             debug("value is: " + value);
>             </javascript>
>         </fd:on-value-changed>
> </fd:field>
>
> Then in my log, when I select multiple values (say Cat and Mouse) in the
> first and a single value (say Tiger) in the second I get:
> 10/09/2013 16:16:00 PM: DEBUG: Came here 1
> 10/09/2013 16:16:00 PM: DEBUG: value is: [Ljava.lang.Object;@8c3fe4
> 10/09/2013 16:16:00 PM: DEBUG: Came here 2
> 10/09/2013 16:16:00 PM: DEBUG: value is: Tiger
>
> Question: how do I get the actual values that the user chose (say Cat
> and Mouse) in the multi-value field?  Should I use a different method
> than the one I used for the single select field and which seems to work?
>
> Paul
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message