cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johannes Textor <jc.tex...@gmx.de>
Subject Re: [CForms] How to set multivalue widget's values ?
Date Mon, 21 Jun 2004 06:35:47 GMT
Hi Derek + all,

I got this solved in the meantime. Actually I had to create a temporary
array and then set the multivalue model to this array:

var model = form.getModel();

var rubriken = Array();

for( i = 0 ; i < size ; i ++ )
    rubriken[i] = new java.lang.Integer(val[i]);

model.rubriken = rubriken;

Notice the difference to the code quoted below: Modifying the model
directly did NOT work, as it is actually an object of type widget and 
something
gets messed up. This is because internally, a setter method is called when
assigning something to model.rubriken. Took me some hours to figure this
out, as I'm a CForms beginner :)

I think I will put a stripped-down version of my article management on the
wiki when I'm done - it's based on CForms + Woody + Hibernate and uses
a few more widgets than the present sample.

Derek, you can read values from the model like this:

var model = form.getModel();
var vals = model.rubriken // retrieve array from multivalue widgets

Now, vals is an array which contains all the values of the options 
selected by
the user.

Derek Hohls wrote:

>And maybe the same person knows how to
>*get* the values from the CForm multivalue widget
>and display them using a JXTemplate loop??
>
>A sample showing both of these would be *very*
>helpful and (IMO) needs to be  a part of the
>Cocoon forms samples.
>
>Thanks
>Derek
>
>  
>
>>>>jc.textor@gmx.de 2004/06/20 09:25:06 PM >>>
>>>>        
>>>>
>Hi all,
>
>I'm going nuts trying to set values in a CForm multivalue widget.
>
>I obtained the Form model with:
>
>var model = form.getModel();
>
>Then I tried to set the values like this:
>
>model.rubriken = Array(size);
>for( i = 0 ; i < size; i++)
>    model.rubriken[i] = new java.lang.Integer(val[i]);
>
>When size=0, everything is fine. Otherwise, I get
>
>Cannot set value of field "rubriken" with an object of type 
>org.mozilla.javascript.UniqueTag
>
>When I omit the array declaration, I get null pointer exceptions.
>
>Has anybody done this and can explain me how ?
>
>TIA, Johannes
>
>---------------------------------------------------------------------
>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