Hello,

I'm a CForms newbie trying to use CForms to replace some forms in my current webapplication. In this application users want to see their forms restored to the state they left it in when they revisit the form. I do this by storing the form model in the session object and use it to bind the form before the next showForm:

function showSearchForm(){
   var formId = cocoon.parameters['formId'];
   var form = new Form("forms/search-definition.xml");
   var modelKey = 'forms.' + formId + '.model';
// Restore the form if a previous model is available var lastModel = cocoon.session.getAttribute(modelKey); if ( lastModel != null ){
       cocoon.log.info('Restoring from model ' + modelKey);
       try {
           form.createBinding("forms/" + formId + "-binding.xml");
           form.load(lastModel);
       }
       catch ( x ) {
cocoon.log.error('Error restoring ' + formId + ' using ' + 'forms/search-definition.xml', x);
       }
   }

   form.showForm(formId + "-display");
   cocoon.session.setAttribute(modelKey,form.getModel());
   cocoon.sendPage(formId + "-showresults");
}

The binding file is very simple:

<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding"; path="/">
   <fb:value id="vakgebied" path="vakgebied"/>
   <fb:value id="regid" path="regid"/>
   <fb:value id="iwtr" path="iwtr"/>
</fb:context>

This works ok for simple field widgets. However, the vakgebied field is a multivaluefield widget and throws the following exception:

ERROR (2005-10-13) 15:30.18:317 [flow] (/cmsbrowser/search/wenr.cform) http8600-Processor21/NativeJavaMethod: Error restoring wenr using forms/search-definition.xml java.lang.RuntimeException: Cannot set value of field "vakgebied" with an object of type org.apache.cocoon.forms.flow.javascript.ScriptableWidget at org.apache.cocoon.forms.formmodel.MultiValueField.setValue(MultiValueField.java:171) at org.apache.cocoon.forms.binding.ValueJXPathBinding.doLoad(ValueJXPathBinding.java:103) at org.apache.cocoon.forms.binding.JXPathBindingBase.loadFormFromModel(JXPathBindingBase.java:162) at org.apache.cocoon.forms.binding.ComposedJXPathBindingBase.doLoad(ComposedJXPathBindingBase.java:96) at org.apache.cocoon.forms.binding.ContextJXPathBinding.doLoad(ContextJXPathBinding.java:52) at org.apache.cocoon.forms.binding.JXPathBindingBase.loadFormFromModel(JXPathBindingBase.java:162) at org.apache.cocoon.forms.binding.JXPathBindingBase.loadFormFromModel(JXPathBindingBase.java:176)


How do I restore a multivaluefield widget?

Thanks,
Stefan.


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

Reply via email to