You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Christofer.Dutz@c-ware.de" <ch...@c-ware.de> on 2008/08/26 15:58:25 UTC

Order of Processing inside CForms

Hi,

 

I just ran into a small problem here. Even if I was able to create a
workaround, I would suggest a fix.

 

I created my CForm/JavaFlow application to work stateless, without
continuations. It is here where I ran into a problem when using unions.

It seems the “process” method doesn’t deal with the form-content in a
specific order. When using unions with a state widget, it is important to
set this first. In my case the union was processed before the state widget.
Causing the union not to parse the parameters of my non-default union group.


 

I managed to get everything working, by manuals setting the state-widgets
value manually before calling the process method of the form … 

 

Here the code:

 

                        FormInstance form = new
FormInstance("forms/registration-def.xml");

                        Form model = (Form) form.getModel();

                        FormContext formContext = new
FormContext(getRequest(), Locale.getDefault());

 

                        // Manually set this, otherwise process won't fill
the 

                        // union fields correctly.

// START HACK

                        String rateType =
getRequest().getParameter("rate-type");

                        model.lookupWidget("rate-type").setValue(rateType);

// END HACK

                        model.process(formContext);

 

                        if (!model.validate()) {

                              // Send the form again with the error messages

} else {

                              // Do the post form processing

}

 

By evaluating state-fields first, this would not be needed. 

As everything is working for me now, this is no urgent case. I just thought,
that if someone puts his hand on the code, maybe he could fix this while he
is at it ;-)

Chris 

 

[ C h r i s t o f e r  D u t z ]

C-Ware IT-Service
Inhaber
Dipl. Inf. Christofer Dutz
Karlstraße. 104, 64285 Darmstadt

fon:  0 61 51 / 27315 - 61
fax:  0 61 51 / 27315 - 64
mobil:  0171 / 7 444 2 33
email:   <ma...@c-ware.de> christofer.dutz@c-ware.de
 <http://www.c-ware.de/> http://www.c-ware.de

FA Darmstadt: 07 813 60581