cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Derek Hohls" <DHo...@csir.co.za>
Subject [REPOST] Setting multi-value widget values for dynamically createdforms
Date Tue, 03 Jun 2008 07:13:41 GMT
I am reposting in the hope that someone can find a 
few moments to look at this - I'm sure I am missing
something simple, but cannot see what it is...

>>> On 2008/05/21 at 12:55, in message <48341BB8.5CE9.00D4.0@csir.co.za>, "Derek
Hohls" <DHohls@csir.co.za> wrote:
I have a dynamically created form which I then access from flowscript

  var qit = newForm.getWidget().getChildren();
   if (qit != null) {
   while ( qit.hasNext() ) {  
       fwidget = qit.next() ;
      ...

to get each widget.  I now need to pre-select some values for
all of the multi-value widgets.  (Note that the widget below has a 
datatype of string).

Approach 1 is what I *think* is correct; Approach 2 I know is
wrong but it does confirm that the widget I am accessing is
a MultiValueField.

Any ideas as to how to make this work properly?

Thanks
Derek

(Side note:  if I omit this step, the rest of the form displays
as expected, and values for other widget types are set OK.)


Approach 1:

var values = java.lang.reflect.Array.newInstance(java.lang.String, 10);
values[0] = "Option 1";
fwidget.setValue(values); //NB also tried fwidget.setValues(values);

Result 1:

java.lang.NullPointerException
at org.apache.cocoon.forms.formmodel.MultiValueField.setValues(MultiValueField.java:190)
at org.apache.cocoon.forms.formmodel.MultiValueField.setValue(MultiValueField.java:180)
...


Approach 2:

fwidget.setValue("Option 1");

Result 2:

java.lang.RuntimeException: Cannot set value of field "q-25--6" with an object of type java.lang.String
at org.apache.cocoon.forms.formmodel.MultiValueField.setValue(MultiValueField.java:182)
...




-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice,
and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

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 



-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice,
and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

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