You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Stefan Warringa <co...@swarringa.myfastmail.com> on 2005/10/13 21:05:11 UTC
CForms: restoring multivaluefield widgets
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: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: CForms: restoring multivaluefield widgets
Posted by Stefan Warringa <co...@swarringa.myfastmail.com>.
On Fri, 14 Oct 2005 13:52:07 +0200, "Jean-Baptiste Quenot"
<jb...@anyware-tech.com> said:
> * Stefan Warringa:
>
> > How do I restore a multivaluefield widget?
>
> With <fb:multi-value id="widgetName" parent-path="enclosingElementName"
> row-path="elementName"/>
> --
> Jean-Baptiste Quenot
> Systèmes d'Information
> ANYWARE TECHNOLOGIES
> Tel : +33 (0)5 61 00 52 90
> Fax : +33 (0)5 61 00 51 46
> http://www.anyware-tech.com/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
OK, I had missed that tag in the bean binding sample. The exception is
gone now but restore still doesn't work. I've looked at the code for
MultiValueField and MultiValueJXPathBinding and it looks like I need to
use the getValue method to get the selected values, but a binding like
<fb:multivalue id="vakgebied" parent-path="." row-path="value"/>
doesn't work. I've tried several combinations of parent and row path but
all without success. What path attributes do I have to use?
BR,
Stefan.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: CForms: restoring multivaluefield widgets
Posted by Jean-Baptiste Quenot <jb...@anyware-tech.com>.
* Stefan Warringa:
> How do I restore a multivaluefield widget?
With <fb:multi-value id="widgetName" parent-path="enclosingElementName" row-path="elementName"/>
--
Jean-Baptiste Quenot
Systèmes d'Information
ANYWARE TECHNOLOGIES
Tel : +33 (0)5 61 00 52 90
Fax : +33 (0)5 61 00 51 46
http://www.anyware-tech.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org