Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 37169 invoked from network); 21 Jun 2004 11:35:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 21 Jun 2004 11:35:48 -0000 Received: (qmail 23982 invoked by uid 500); 21 Jun 2004 11:34:23 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 23246 invoked by uid 500); 21 Jun 2004 11:34:11 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: users@cocoon.apache.org Delivered-To: mailing list users@cocoon.apache.org Received: (qmail 22594 invoked by uid 99); 21 Jun 2004 11:34:01 -0000 Received: from [213.165.64.20] (HELO mail.gmx.net) (213.165.64.20) by apache.org (qpsmtpd/0.27.1) with SMTP; Mon, 21 Jun 2004 04:34:01 -0700 Received: (qmail 23381 invoked by uid 65534); 21 Jun 2004 11:33:56 -0000 Received: from p50871B72.dip.t-dialin.net (EHLO gmx.de) (80.135.27.114) by mail.gmx.net (mp027) with SMTP; 21 Jun 2004 13:33:56 +0200 X-Authenticated: #2236490 Message-ID: <40D6C768.3050509@gmx.de> Date: Mon, 21 Jun 2004 13:32:56 +0200 From: Johannes Textor User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040113 X-Accept-Language: en-us, en MIME-Version: 1.0 To: users@cocoon.apache.org Subject: Re: [CForms] How to set multivalue widget's values ? References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi Derek, now while trying out your code I discovered something that really has nothing to do with CForms:
  • A Selection 1: ${atheme}
  • the syntax is simply wrong. it should say
  • A Selection 1: ${thisTheme}
  • now this should help ;) Derek Hohls wrote: >Johannes > >Still no luck - I have tried adding in some more variables >to test; and it looks like the values are being stored in >the array OK... > > var values = Array(); > > for( i = 0; i < model.theme.length ; i ++ ) > values[i] = model.theme[i]; > > var test0 = values[0]; > var test1 = values[1]; > > cocoon.sendPage("ijx-page", { "atheme":values, "theme":values, >"test0":test0; "test1":test1 }); > >The output for test0 or test1 matches the mulivalue widget >selection BUT the "values" output in the JX for-each loop is >still the strange references as before... > >What else to try ?? >Derek > > > >>>>jc.textor@gmx.de 2004/06/21 11:49:16 AM >>> >>>> >>>> >Derek, > >I actually don't use the values this way, I insert them directly into >the database >after the form was submitted. >Let's examine your code though, since you should be able to use the >values in jxt >as well. > > var model = form.getModel(); > var atheme = model.theme; /* theme is multiselect box */ > cocoon.sendPage("jxpage", { "atheme":atheme, "theme":model.theme }); > >There is something subtile here. "model.theme" is an object of type >ScriptableWidget, >so JXT will be confused when you pass it as a collection. (and print >out the "value" >org.apache.cocoon.forms.flow.javascript.ScriptableWidget@e1fb6c) > >I suggest retrieving the values to a native JavaScript array and >passing that one >to JXT. > > var model = form.getModel(); > var values = Array(); > for( i = 0; i < model.theme.length ; i ++ ) > values[i] = model.theme[i]; > cocoon.sendPage("jxpage", { "atheme":values, "theme":values }); > >Does this work? It's just the solution to my problem applied in the >opposite direction :) > >HTH, Johannes > >Derek Hohls wrote: > > > >>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: >> >> >>
  • Selection: ${theme}
  • >>
    >> >> >>
  • A Selection 1: ${atheme}
  • >>
    >> >> >>
  • A Selection 2: ${thisTheme}
  • >>
    >> >>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