cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Derek Hohls" <>
Subject Re: [CForms] How to set multivalue widget's values ?
Date Mon, 21 Jun 2004 09:27:18 GMT

I have tried what you suggested - the problem
is displaying the results in the JXTemplate - could 
you please post your code snippet, as what I have 
tried does not work....


in flowscript:
 var model = form.getModel();  
  var atheme = model.theme; /* theme is multiselect box */
  cocoon.sendPage("jxpage", { "atheme":atheme, "theme":model.theme 

in jxtemplate:

  <jx:forEach var="thisTheme" items="theme">
    <li>Selection: ${theme}</li>
  <jx:forEach var="thisTheme" items="atheme">
    <li>A Selection 1: ${atheme}</li>
  <jx:forEach var="thisTheme" items="atheme">
    <li>A Selection 2: ${thisTheme}</li>

in output html:

A Selection 1:
A Selection 2:

I am obviously missing some crucial conversion ?!


>>> 2004/06/21 08:35:47 AM >>>
Hi Derek + all,

I got this solved in the meantime. Actually I had to create a
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 
gets messed up. This is because internally, a setter method is called
assigning something to model.rubriken. Took me some hours to figure
out, as I'm a CForms beginner :)

I think I will put a stripped-down version of my article management on
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.
>>>> 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 
>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: 
>For additional commands, e-mail: 

To unsubscribe, e-mail: 
For additional commands, e-mail: 

This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message