You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Jorg Heymans <jh...@domek.be> on 2004/11/11 11:28:52 UTC

unrolling the form loop (was Re: Repeater insert-node does not bind??)

Joerg Heinicke wrote:
> 
>> [1] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=109820425417800&w=2
> 
> 
> The problem with your use case described in that mail is simply that 
> form.save() is not called and so no binding is executed at all. 
> Otherwise you have a problem if the form is not submitted at the end: 
> You won't get the original model back. If that's not a problem for you 
> you can "unroll" the form.showForm() function and add a form.save() into 
> the while loop.
> 

Actually tried this now ...

i replaced

  var form = new Form(...);
  form.createBinding(...);
  form.load(mybean);
  form.showForm("uri");

with

  var form = new Form(...);
  form.createBinding(...);
  form.load(mybean);
  while(true){
    cocoon.sendPageAndWait("uri", {"CocoonFormsInstance" : form.form});
    print("submitted");
    form.save(mybean);
  }

but ofcourse it doesn't exit the while loop.

How do i differentiate between the repeater action submit and the form 
submit? It also doesn't same to be executing the save properly because 
the repeater is not updating anymore after adding/removal.

Or did i not correctly unroll the loop in the first place?


Regards
Jorg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: unrolling the form loop (was Re: Repeater insert-node does not bind??)

Posted by Jorg Heymans <jh...@domek.be>.
<snipped what="perfectly fine code">

> I have public get and set methods for the ArrayList "participants" in 
> mybean with a binding that used to work before

well i meant here "before i messed with it and forgot all about it".

Bean is now updating fine during repeater add/remove actions.
Thanks a lot for your help Joerg.

Regards
Jorg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: unrolling the form loop (was Re: Repeater insert-node does not bind??)

Posted by Jorg Heymans <jh...@domek.be>.

Joerg Heinicke wrote:
> 
> 
> The function showForm() is a bit more complex. You need at least the 
> this.form.process(formContext) stuff which also returns the value 
> finished for the while loop.
> 
> http://svn.apache.org/viewcvs.cgi/cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/Form.js?rev=54109&view=markup 

Thanks for pointing that out.

The unrolled loop now looks like (form2 is my formobject)

--------------
var bizData = new Object();
bizData[Packages.o.a.c.f.transformation.FormsPipelineConfig.CFORMSKEY] 
       	=form2.form;
if (form2.form.locale == null){
     form2.form.locale = java.util.Locale.getDefault();
}
bizData["locale"] = form2.form.locale;

while (true){
  var result = cocoon.sendPageAndWait("uri",{"CocoonFormsInstance": 
form2.form});
  var formContext = new Packages.o.a.c.forms.FormContext(
cocoon.request, form2.form.locale);

//could not access form2.form.avalonContext for some reason
//var objectModel = 
//org.apache.cocoon.components.ContextHelper.getObjectModel(form2.form.avalonContext);
//   org.apache.cocoon.components.flow.flowHelper.setContextObject(
//objectModel, bizData);

  var finished = form2.form.process(formContext);
  //this causes an exception
  form2.binding.saveFormToModel(form2.form, campaignFormBean);
  if (finished){
     print("finished form");
     break;
  }
  print("redisplaying form");
}
-------------------

But i'm getting Exception trying to remove xpath .; Cannot modify 
property: mybean.participants; java.lang.reflect.InvocationTargetException

This happens when nodes are removed from the repeater.

I have public get and set methods for the ArrayList "participants" in 
mybean with a binding that used to work before
<fb:repeater id="participants" parent-path="." row-path="participants">

Did i step on something i shouldn't ?

regards
Jorg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: unrolling the form loop (was Re: Repeater insert-node does not bind??)

Posted by Joerg Heinicke <jo...@gmx.de>.
On 11.11.2004 11:28, Jorg Heymans wrote:

>  var form = new Form(...);
>  form.createBinding(...);
>  form.load(mybean);
>  while(true){
>    cocoon.sendPageAndWait("uri", {"CocoonFormsInstance" : form.form});
>    print("submitted");
>    form.save(mybean);
>  }
> 
> but ofcourse it doesn't exit the while loop.

The function showForm() is a bit more complex. You need at least the 
this.form.process(formContext) stuff which also returns the value 
finished for the while loop.

http://svn.apache.org/viewcvs.cgi/cocoon/trunk/src/blocks/forms/java/org/apache/cocoon/forms/flow/javascript/Form.js?rev=54109&view=markup

Joerg

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org