You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by BURGHARD Éric <er...@systheo.com> on 2004/11/02 13:47:14 UTC

Repeater insert-node does not bind??

Hi Everyone

While working on a cforms reapeater (bind with an XML doc), I thought that
when a new row is created, it would bind directly to the node specified in
the binding <fb:on-insert-row> but it seems that this is not the case and
the row will be either empty, either filled in by js before showing the
form once again

Is it possible to make the new row bind on the <fb:on-insert-row> node on
creation?

Thanks for the thoughts

Tibor



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


Re: Repeater insert-node does not bind??

Posted by oceatoon <t....@systheo.com>.
Thanks for the info Joerg
Allways good too know :)
Cheers
Tibor

Joerg Heinicke wrote:

> On 18.11.2004 15:31, oceatoon wrote:
>> I'm doing a basic repeater  widget with an add button,
>> I thought that when adding a row the new row would automatically bind to
>> the insert-node (<item id="" key="cocorico" qte="0"/>)but my key is
>> allways empty??? So in the mean time I'm doing it through flow. But am I
>> doing somthing wrong, is this supposed to be like this ?
> 
> Ah, I think I know what you want to do. Immediately after adding a new
> row you want to have some values prefilled? The binding happens just on
> form.save(xml). Only at that time the item node is inserted. Before it's
> just a matter of the form without any binding involved. This is
> something for flowscript indeed. It should be possible using
> fd:repeater-action specifying fd:on-activate I think:
> http://cocoon.apache.org/2.1/userdocs/forms/widget_repeater_action.html
> 
> Joerg



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


Re: Repeater insert-node does not bind??

Posted by Joerg Heinicke <jo...@gmx.de>.
On 18.11.2004 15:31, oceatoon wrote:
> I'm doing a basic repeater  widget with an add button,
> I thought that when adding a row the new row would automatically bind to the
> insert-node (<item id="" key="cocorico" qte="0"/>)but my key is allways
> empty??? So in the mean time I'm doing it through flow. But am I doing
> somthing wrong, is this supposed to be like this ? 

Ah, I think I know what you want to do. Immediately after adding a new 
row you want to have some values prefilled? The binding happens just on 
form.save(xml). Only at that time the item node is inserted. Before it's 
just a matter of the form without any binding involved. This is 
something for flowscript indeed. It should be possible using 
fd:repeater-action specifying fd:on-activate I think:
http://cocoon.apache.org/2.1/userdocs/forms/widget_repeater_action.html

Joerg

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


Re: Repeater insert-node does not bind??

Posted by oceatoon <t....@systheo.com>.
I'm doing a basic repeater  widget with an add button,
I thought that when adding a row the new row would automatically bind to the
insert-node (<item id="" key="cocorico" qte="0"/>)but my key is allways
empty??? So in the mean time I'm doing it through flow. But am I doing
somthing wrong, is this supposed to be like this ? 
Thanks for the help 
Tibor  

Joerg Heinicke wrote:

> On 16.11.2004 10:46, oceatoon wrote:
> 
>> So I'm back to my first question, because I had the initial binding for
>> my repeater , I thought I had to add another bind in the on-insert-row.
>> but it doesn't bind on creation of the new node,
> 
> Ok.
> 
>> ***************************************************************
>> <fb:repeater id="beds" parent-path="beds" row-path="item">
>>                 <fb:identity>
>>                 <fb:value id="idbed" path="@id">
>>                     <fd:convertor datatype="long"/>
>>                 </fb:value>
>>                 </fb:identity>
>> 
>> <fb:on-bind>
>> <fb:value id="size" path="@key" direction="load"/>
>> <fb:value id="bedquanti" path="@qte"><fd:convertor
>> datatype="string"/></fb:value>
>>                 </fb:on-bind>
>> 
>>                 <fb:on-insert-row>
>>                     <fb:insert-node>
>>                         <item id="" key="cocorico" qte="0"/>
>>                     </fb:insert-node>
>>                 </fb:on-insert-row>
>> </fb:repeater>
>> 
>> Even though I get my new row on insert-node but the "size" widget doesn't
>> take the "cocorico" value set as the initial value of the newly inserted
>> node ??
> 
> Hey, but that's something completely different :-) Can you describe you
> use case? It's difficult to understand the goal of it.
> 
> Joerg



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


Re: Repeater insert-node does not bind??

Posted by Joerg Heinicke <jo...@gmx.de>.
On 16.11.2004 10:46, oceatoon wrote:

> So I'm back to my first question, because I had the initial binding for my
> repeater , I thought I had to add another bind in the on-insert-row.
> but it doesn't bind on creation of the new node, 

Ok.

> ***************************************************************
> <fb:repeater id="beds" parent-path="beds" row-path="item">
>                 <fb:identity>
>                 <fb:value id="idbed" path="@id">
>                     <fd:convertor datatype="long"/>
>                 </fb:value>
>                 </fb:identity>
> 
> <fb:on-bind>
> <fb:value id="size" path="@key" direction="load"/>
> <fb:value id="bedquanti" path="@qte"><fd:convertor
> datatype="string"/></fb:value>
>                 </fb:on-bind>
> 
>                 <fb:on-insert-row>
>                     <fb:insert-node>
>                         <item id="" key="cocorico" qte="0"/>
>                     </fb:insert-node>
>                 </fb:on-insert-row>
> </fb:repeater>  
> 
> Even though I get my new row on insert-node but the "size" widget doesn't
> take the "cocorico" value set as the initial value of the newly inserted
> node ??  

Hey, but that's something completely different :-) Can you describe you 
use case? It's difficult to understand the goal of it.

Joerg

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


Re: Repeater insert-node does not bind??

Posted by oceatoon <t....@systheo.com>.
Thanks Joerg

So I'm back to my first question, because I had the initial binding for my
repeater , I thought I had to add another bind in the on-insert-row.
but it doesn't bind on creation of the new node, 
***************************************************************
<fb:repeater id="beds" parent-path="beds" row-path="item">
                <fb:identity>
                <fb:value id="idbed" path="@id">
                    <fd:convertor datatype="long"/>
                </fb:value>
                </fb:identity>

<fb:on-bind>
<fb:value id="size" path="@key" direction="load"/>
<fb:value id="bedquanti" path="@qte"><fd:convertor
datatype="string"/></fb:value>
                </fb:on-bind>

                <fb:on-insert-row>
                    <fb:insert-node>
                        <item id="" key="cocorico" qte="0"/>
                    </fb:insert-node>
                </fb:on-insert-row>
</fb:repeater>  

Even though I get my new row on insert-node but the "size" widget doesn't
take the "cocorico" value set as the initial value of the newly inserted
node ??  

Thanks Joerg 
Regards
Tibor


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


Re: Repeater insert-node does not bind??

Posted by Joerg Heinicke <jo...@gmx.de>.
On 15.11.2004 22:37, oceatoon wrote:

> Sorry for not answering I was a bit away 
> but thanks for the reply.
> happy to know it is feasable :)
> 
> I tried adding the fb:value binding in the insert node, but I'm very dubious
> about the syntax??? and it doesn't seem to work 
> 
> <fb:insert-row>
>         <mynode id=""><desc>blabla</desc></mynode>
>         <fb:value id="desc" path="mynode/desc"/>
> </fb:on-insert-row>

Eh, no. More like this one:
http://svn.apache.org/viewcvs.cgi/cocoon/trunk/src/blocks/forms/samples/forms/form2_bind_xml.xml?rev=30942&view=auto

   <fb:repeater id="contacts" parent-path="contacts" row-path="contact">
   ...
     <fb:on-bind>
       ...
       <fb:value id="firstname" path="firstname" />
       ...
     </fb:on-bind>

   ...

     <fb:on-insert-row>
       <fb:insert-node>
         <contact id="" row-state="new">
           <firstname/><lastname/><phone nr=""/><email/>
         </contact>
       </fb:insert-node>
     </fb:on-insert-row>
   </fb:repeater>

Joerg

>>>While working on a cforms reapeater (bind with an XML doc), I thought
>>>that when a new row is created, it would bind directly to the node
>>>specified in the binding <fb:on-insert-row> but it seems that this is not
>>>the case and the row will be either empty, either filled in by js before
>>>showing the form once again
>>>
>>>Is it possible to make the new row bind on the <fb:on-insert-row> node on
>>>creation?
>>
>>IIRC fb:on-insert-row is just about the inserting before the binding
>>itself happens. You need an additional binding specification (fb:value
>>or whatever).

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


Re: Repeater insert-node does not bind??

Posted by oceatoon <t....@systheo.com>.
Sorry for not answering I was a bit away 
but thanks for the reply.
happy to know it is feasable :)

I tried adding the fb:value binding in the insert node, but I'm very dubious
about the syntax??? and it doesn't seem to work 

<fb:insert-row>
        <mynode id=""><desc>blabla</desc></mynode>
        <fb:value id="desc" path="mynode/desc"/>
</fb:on-insert-row>

Thanks for the help
Tibor

Joerg Heinicke wrote:

> On 02.11.2004 13:47, BURGHARD Éric wrote:
> 
>> While working on a cforms reapeater (bind with an XML doc), I thought
>> that when a new row is created, it would bind directly to the node
>> specified in the binding <fb:on-insert-row> but it seems that this is not
>> the case and the row will be either empty, either filled in by js before
>> showing the form once again
>> 
>> Is it possible to make the new row bind on the <fb:on-insert-row> node on
>> creation?
> 
> IIRC fb:on-insert-row is just about the inserting before the binding
> itself happens. You need an additional binding specification (fb:value
> or whatever).
> 
> Joerg



---------------------------------------------------------------------
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


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

Posted by Jorg Heymans <jh...@domek.be>.
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: Repeater insert-node does not bind??

Posted by Joerg Heinicke <jo...@gmx.de>.
On 03.11.2004 15:21, Jorg Heymans wrote:

> Is this valid for [1] as well ?

No, that's different. Read below.

> Can you elaborate a bit what you mean by this additional binding 
> specification?

With binding specification (or probably better binding definition) I 
mean the fb:* stuff in the binding file. With fb:on-insert-row you 
specify the node (for XML) or the method (for binding to a bean) which 
is executed after form.save() for each row that was inserted. Directly 
after the nodes have been added the values are bound to that newly 
created nodes. Therefore you need a fb:value or whatever is appropriate 
in your case.

> [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.

Joerg

>>> While working on a cforms reapeater (bind with an XML doc), I thought 
>>> that
>>> when a new row is created, it would bind directly to the node 
>>> specified in
>>> the binding <fb:on-insert-row> but it seems that this is not the case 
>>> and
>>> the row will be either empty, either filled in by js before showing the
>>> form once again
>>>
>>> Is it possible to make the new row bind on the <fb:on-insert-row> 
>>> node on
>>> creation?
>>
>> IIRC fb:on-insert-row is just about the inserting before the binding 
>> itself happens. You need an additional binding specification (fb:value 
>> or whatever).

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


Re: Repeater insert-node does not bind??

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

Is this valid for [1] as well ?

Can you elaborate a bit what you mean by this additional binding 
specification?

Thanks
Jorg

[1] http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=109820425417800&w=2

Joerg Heinicke wrote:
> On 02.11.2004 13:47, BURGHARD Éric wrote:
> 
>> While working on a cforms reapeater (bind with an XML doc), I thought 
>> that
>> when a new row is created, it would bind directly to the node 
>> specified in
>> the binding <fb:on-insert-row> but it seems that this is not the case and
>> the row will be either empty, either filled in by js before showing the
>> form once again
>>
>> Is it possible to make the new row bind on the <fb:on-insert-row> node on
>> creation?
> 
> 
> IIRC fb:on-insert-row is just about the inserting before the binding 
> itself happens. You need an additional binding specification (fb:value 
> or whatever).
> 
> Joerg


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


Re: Repeater insert-node does not bind??

Posted by Joerg Heinicke <jo...@gmx.de>.
On 02.11.2004 13:47, BURGHARD Éric wrote:

> While working on a cforms reapeater (bind with an XML doc), I thought that
> when a new row is created, it would bind directly to the node specified in
> the binding <fb:on-insert-row> but it seems that this is not the case and
> the row will be either empty, either filled in by js before showing the
> form once again
> 
> Is it possible to make the new row bind on the <fb:on-insert-row> node on
> creation?

IIRC fb:on-insert-row is just about the inserting before the binding 
itself happens. You need an additional binding specification (fb:value 
or whatever).

Joerg


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