Hello Robby!
I solved my problem.

In form defenition file:

<fd:multivaluefield id="mm">
<fd:label>Name:</fd:label>
<fd:datatype base="string"/>
<fd:selection-list>
<fd:item value="IVAN"/>
<fd:item value="PETR"/>
<fd:item value="LIDA"/>
<fd:item value="GEORG"/>
<fd:item value="FEDYA"/>
</fd:selection-list>
</fd:multivaluefield>

In binding file:

<fb:context path="data" xmlns:fb="http://apache.org/cocoon/forms/1.0#binding";>
<fb:multi-value id="mm" parent-path="." row-path="mm" />
</fb:context>

In data for binding file:

<data>
<mm>IVAN</mm>
<mm>LIDA</mm>
</data>

In flowscript file:

function loadDocument(uri) {
    var parser = null;
    var source = null;
    var resolver = null;
    try {
parser = cocoon.getComponent(Packages.org.apache.excalibur.xml.dom.DOMParser.ROLE); resolver = cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.ROLE);
        source = resolver.resolveURI(uri);
var is = new Packages.org.xml.sax.InputSource(source.getInputStream());
        is.setSystemId(source.getURI());
        return parser.parseDocument(is);
    } finally {
        if (source != null)
            resolver.release(source);
        cocoon.releaseComponent(parser);
        cocoon.releaseComponent(resolver);
    }
}
cocoon.load("servlet:forms:/resource/internal/flow/javascript/Form.js");
function registration() {
    var form = new Form("cocoon://form.def.xml");
    form.createBinding("cocoon://binding.xml");
    var document = loadDocument("cocoon://dataForMM.xml");
    form.load(document);
    form.showForm("registration-display-pipeline");

    var viewData = { "username" : form.getChild("mm").getValue()[0] }
    cocoon.sendPage("registration-success-pipeline", viewData);
}

That is all. The row with value "LIDA" and "IVAN" are "selected".
Thanks for help.


Hi Serge,

I don't think it's possible to accomplish your requirements directly in the form definition but it should be straightforward if you do it programmatically.

Since it's a multivalue-widget you can set the Options (values to pick from) by using |void| |*setSelectionList <http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/forms/formmodel/MultiValueField.html#setSelectionList%28org.apache.cocoon.forms.datatype.SelectionList%29>*||(SelectionList <http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/forms/datatype/SelectionList.html> selectionList)|

If you want to set the default selected values then you have to use the | void| |*setValues <http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/forms/formmodel/MultiValueField.html#setValues%28java.lang.Object[]%29>*||(Object <http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html>[] values)|

||

|I am not sure if have a very simple example at hand. But if you still can't get things working programmatically... let me know.|

||

|Robby|


Reply via email to