You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by H....@MI.unimaas.nl on 2004/12/01 00:25:24 UTC

[CForms] Losing identity values in repeater. Please help!

Hi,

I finally have my repeater working, but now something odd happens: I loose
the value of the widget that is defined as identity, which results in all
existing rows being added as "new". I suppose I'm doing something wrong, but
I cannot figure out what.

And it gets wierder by the minute:
When debugging I can see that the identity widgets are filled in correctly,
but after submit they are empty and thus every row is considered to be new
and is then added.

However, if I display the widget holding the identity the identity is
retained and only newly added rows are added. In other words, the repeater
behaves as expected.
But, if I display the identity widget with styling="output" the identities
get lost again.

What's wrong?

        <fd:repeater id="appointments">
            <fd:widgets>
                <fd:field id="ID">
                    <fd:label>ID</fd:label>
                    <fd:datatype base="string"/>
                </fd:field>
                <fd:field id="appointmentDate">
                    <fd:label>Datum</fd:label>
                    <fd:datatype base="date"/>
                </fd:field>
                <fd:field id="appointmentTime">
                    <fd:label>Tijd</fd:label>
                    <fd:datatype base="date"/>
                </fd:field>

                <fd:field id="appointmentPerson">
                    <fd:label>Naam</fd:label>
                    <fd:datatype base="string"/>
                </fd:field>
            
        </fd:widgets>
        </fd:repeater>

        <fd:repeater-action id="addAppointment" 
           action-command="add-row" repeater="appointments">
            <fd:label>Voeg afspraak toe</fd:label>
        </fd:repeater-action>
    </fd:widgets>


   <fb:repeater id="appointments" parent-path="."
row-path="lists/appointments">
      <fb:identity>
         <fb:value id="ID" path="id"/>
      </fb:identity>
      <fb:on-bind>
         <!-- executed on updates AND right after the insert -->
    <fb:custom id="appointmentDate" path="date" class="mycustombinding"/> 
    <fb:custom id="appointmentTime" path="time" class="mycustombinding"/> 
    <fb:custom id="appointmentPerson" path="person"
class="mycustombinding"/>  
            
      </fb:on-bind>
      <fb:on-delete-row>
         <fb:delete-node/>
      </fb:on-delete-row>
      <fb:on-insert-row>
        <fb:insert-bean
            classname="mybean"
            addmethod="add" />
      </fb:on-insert-row>
   </fb:repeater>

Thanks.

Bye, Helma

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


Re: [CForms] Losing identity values in repeater. Please help!

Posted by Joerg Heinicke <jo...@gmx.de>.
On 01.12.2004 00:25, H.vanderLinden@MI.unimaas.nl wrote:

> I finally have my repeater working, but now something odd happens: I loose
> the value of the widget that is defined as identity, which results in all
> existing rows being added as "new". I suppose I'm doing something wrong, but
> I cannot figure out what.

Yes, and this time it's more clear and easier to fix :-)

> But, if I display the identity widget with styling="output" the identities
> get lost again.
> 
> What's wrong?

The usage of fd:field for ID implies the submit of request parameter ID 
that's read. As there is no request param sent when using 
styling="output" (only text is generated, no inputs) the new value is 
'null'. I use the ID stuff myself really often, but have done it always 
using fd:output, as this does not expect a request param and the ID is 
preserved.

>                 <fd:field id="ID">
>                     <fd:label>ID</fd:label>
>                     <fd:datatype base="string"/>
>                 </fd:field>

=> <fd:output id="ID">

>    <fb:repeater id="appointments" parent-path="."
> row-path="lists/appointments">
>       <fb:identity>
>          <fb:value id="ID" path="id"/>

Additionally I have added direction="save" to my ID fields, so that they 
can not even overwritten in flowscript. On the beans themselves I do not 
even have a setter for id, as only the database sets the id and nobody 
should manipulate them.

Joerg

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