Christina,

I suspect the problem could be that you need to force a redisplay of the page for the value to be shown - in all the instances I set selection list values, the form always gets re-displayed. Depending on your application you could do this via an action or specifying submit-on-change="true" in the form template. There may be some other mechanism (such as calling showFom again), or some other reason for the problem, but I've only just started using cocoon so who knows!

Anyway, the flowscript I use to set the initial value is as follows:

var form new Form(FormDefinitionURI);
var widget = form.lookupWidget("mySelectionListFieldWidget");
widget.setValue("InitialSelectedValue");
form.showForm("my-display-pipeline");

which seems to be what you're using, so I suspect not redisplaying your page after a subsequent setValue is the problem.

Scott.

Christina wrote:

Scott,
  I used the widget.setValue("selectedValue"), but what's shown in the form
is still the default value. this setValue works for other fields, but
obviously it doesn't work for fields with a selection list
  Thanks
Christina
----- Original Message -----
From: "Scott Yeadon" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 28, 2004 3:37 PM
Subject: Re: [CForm] how to setValue for a field of selection list?




Christina,

If you're saving the last selected value to a database and want to set
the value to what the user selected last save, you need to be able to
indicate which value was last selected, either via database field, XML
attribute (if an XML database), or preferences file, or some other
mechanism. If you know what was last selected you can then use the
setValue call.

Scott.

Christina wrote:



No, I mean the selection list is already there.
What I want to do is to select a value from the list and show it on the
page, instead of the default value every time.
for example,
at first use select a value and save it. when he access this page again,


I


fetch the value from db and set the value to that droplist.
user can select another value if he want to change it.

----- Original Message -----
From: "Stephane Delort" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 28, 2004 1:16 AM
Subject: Re: [CForm] how to setValue for a field of selection list?






Hi Christina,

maybe you should take a look  at the "setSelectionList" function.


here is a sample of code I use to fill mine (as javascript in a cform template):

var langWidget = event.source.lookupWidget("../lang");
size = 10;
for( var i=1; i &lt; size; i++) {
   data.lang[i] = {value: languages.getValue(i), label:




languages.getLabel(i)};




}
langWidget.setSelectionList(data.lang, "value", "label");

//languages is an home made java class


hope this help, Stephane



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to