cocoon-users mailing list archives

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

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....

ie. 

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>
  
  <jx:forEach var="thisTheme" items="atheme">
    <li>A Selection 1: ${atheme}</li>
  </jx:forEach>
    
  <jx:forEach var="thisTheme" items="atheme">
    <li>A Selection 2: ${thisTheme}</li>
  </jx:forEach>   

in output html:

Selection:
org.apache.cocoon.forms.flow.javascript.ScriptableWidget@e1fb6c 
A Selection 1:
org.apache.cocoon.forms.flow.javascript.ScriptableWidget@41825e 
A Selection 2:
org.apache.cocoon.generation.JXTemplateGenerator$Expression@d622e5 

I am obviously missing some crucial conversion ?!

Thanks
Derek

>>> jc.textor@gmx.de 2004/06/21 08:35:47 AM >>>
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 


-- 
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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message