While we're at it... 

Here is some code that shows how you can set a selectionlist dynamically
from flowscript:

---------------------------------------------------------------------
importClass(Packages.org.apache.cocoon.forms.datatype.StaticSelectionLis
t);



cocoon.load("servlet:forms:/resource/internal/flow/javascript/Form.js");
var form = new Form("your form definition pipeline");
var formWidget = form.form;

var projectNoteWidget = formWidget.lookupWidget("projectNote");


var possibleValues = cocoon.getComponent("someComponent").getXXX();

//!!! You have to pass the datatype of the actual Widget on which you
want to set the selectionlist and this widget has to implement the
DataWidget interface 
var projectNoteValueList = new
StaticSelectionList(projectNoteWidget.getDatatype());   
for (var i=0; i < possibleValues.size(); i++) {
    projectNoteValueList.addItem(possibleValues.get(i));
}
//set the selectionlist on the projectnotewidget
projectNoteWidget.setSelectionList(projectNoteValueList);

//set default value on widget
projectNoteWidget.setValue(3);

---------------------------------------------------------------------

Kind regards,
Robby Pelssers

-----Original Message-----
From: Robby Pelssers [mailto:[email protected]] 
Sent: Saturday, September 19, 2009 1:49 PM
To: [email protected]
Subject: RE: Selecting items on selection-list from flow.

Under the assumption that this field is a direct childwidget of the
form... you do it as follows:

        
cocoon.load("servlet:forms:/resource/internal/flow/javascript/Form.js");
        var form = new Form("your form definition pipeline");
      var formWidget = form.form;

      var projectNoteWidget = formWidget.lookupWidget("projectNote");
      projectNoteWidget.setValue(3);

Cheers,
Robby Pelssers


-----Original Message-----
From: Tomasz Piechowicz [mailto:[email protected]] 
Sent: Saturday, September 19, 2009 8:56 AM
To: [email protected]
Subject: Selecting items on selection-list from flow.

I have simple selection list in my from definition :

<fd:field id="projectNote">
        <fd:label>Ocena projektu: </fd:label>
        <fd:datatype base="double"/>
        <fd:selection-list>
                <fd:item value="2"/>
                <fd:item value="3"/>
                <fd:item value="3.5"/>  
                <fd:item value="4.0"/>
                <fd:item value="4.5"/>
                <fd:item value="5.0"/>
        </fd:selection-list>
</fd:field>

Can anyone tell me how to select an item on list from flow before
showing form to user ?

Regards,
Tomek Piechowicz

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