Carlos Chávez ha scritto:

Simone Masoni wrote:

Can anyone help me in finding a good sample with CForms, with repeater widget bound
to a Collection inside a Bean?

I've tried it using OJB PersistenceBroker, but it doesn't work, I can delete rows
in repeater but then I don't know how to persist the deletion in the DB.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Hi Simone,

are you set the properties auto-update and auto-delete to true for the collection ?

Cheers,
Carlos Chávez.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Yes, I've set these properties to true

This is my tables and codes:

TABLES:

CREATE TABLE passiste
(
 pbcodass varchar(3) NOT NULL,
 pbprogre serial NOT NULL,
 pbdescri char(50),
 pbannota char(50),
 .
 . (many others fields)

 CONSTRAINT passiste_pkey PRIMARY KEY (pbcodass),
 CONSTRAINT passiste_pbprogre_key UNIQUE (pbprogre)
)

CREATE TABLE docassiste
(
 dbprogre serial NOT NULL,
 dbdocume int4,
 dbobblig varchar(1),
 dbannota char(50),
 dbcodass varchar(3),
 CONSTRAINT docassiste_pkey PRIMARY KEY (dbprogre),
CONSTRAINT docassiste_dbcodass_fkey FOREIGN KEY (dbcodass) REFERENCES passiste (pbcodass) ON UPDATE RESTRICT ON DELETE RESTRICT, CONSTRAINT docassiste_dbdocume_fkey FOREIGN KEY (dbdocume) REFERENCES docuassist (dgprogre) ON UPDATE NO ACTION ON DELETE NO ACTION
)


-----------------------------------------------------

REPOSITORY:

<class-descriptor class="w4b.com.cassagest.db.Docassiste" table="DOCASSISTE"> <field-descriptor name="dbprogre" primarykey="true" default-fetch="true" autoincrement="true" sequence-name="public.docassiste_dbprogre_seq" column="DBPROGRE" jdbc-type="INTEGER"/> <field-descriptor name="dbdocume" default-fetch="true" column="DBDOCUME" jdbc-type="INTEGER"/> <field-descriptor name="dbobblig" default-fetch="true" column="DBOBBLIG" jdbc-type="VARCHAR"/> <field-descriptor name="dbannota" default-fetch="true" column="DBANNOTA" jdbc-type="CHAR"/> <field-descriptor name="dbcodass" default-fetch="true" column="DBCODASS" jdbc-type="VARCHAR"/> <reference-descriptor name="dbcodassRef" class-ref="w4b.com.cassagest.db.Passiste" auto-update="true" auto-delete="true" proxy="false">
           <foreignkey field-ref="dbcodass"/>
</reference-descriptor> <reference-descriptor name="dbdocumeRef" class-ref="w4b.com.cassagest.db.Docuassist" auto-update="true" auto-delete="true" proxy="false">
           <foreignkey field-ref="dbdocume"/>
       </reference-descriptor>
   </class-descriptor>


<class-descriptor class="w4b.com.cassagest.db.Passiste" table="PASSISTE"> <field-descriptor name="pbprogre" nullable="false" default-fetch="true" autoincrement="true" sequence-name="public.passiste_pbprogre_seq" column="PBPROGRE" jdbc-type="INTEGER"/> <field-descriptor name="pbdtinval" default-fetch="true" column="PBDTINVAL" jdbc-type="DATE" conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion"/> <field-descriptor name="pbdtfival" default-fetch="true" column="PBDTFIVAL" jdbc-type="DATE" conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion"/> <field-descriptor name="pbdescri" default-fetch="true" column="PBDESCRI" jdbc-type="CHAR"/> <field-descriptor name="pbgglimd" default-fetch="true" column="PBGGLIMD" jdbc-type="SMALLINT"/> <field-descriptor name="pbdtlimd" default-fetch="true" column="PBDTLIMD" jdbc-type="DATE" conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion"/> <field-descriptor name="pbdtlavf" default-fetch="true" column="PBDTLAVF" jdbc-type="DATE" conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion"/> <field-descriptor name="pbnumean" default-fetch="true" column="PBNUMEAN" jdbc-type="SMALLINT"/> <field-descriptor name="pbfamili" default-fetch="true" column="PBFAMILI" jdbc-type="VARCHAR"/> <field-descriptor name="pbachias" default-fetch="true" column="PBACHIAS" jdbc-type="VARCHAR"/> <field-descriptor name="pbunicae" default-fetch="true" column="PBUNICAE" jdbc-type="VARCHAR"/> <field-descriptor name="pbpercen" default-fetch="true" column="PBPERCEN" jdbc-type="NUMERIC"/> <field-descriptor name="pbricvot" default-fetch="true" column="PBRICVOT" jdbc-type="VARCHAR"/> <field-descriptor name="pbimpoun" default-fetch="true" column="PBIMPOUN" jdbc-type="NUMERIC"/> <field-descriptor name="pbimpmax" default-fetch="true" column="PBIMPMAX" jdbc-type="NUMERIC"/> <field-descriptor name="pbvotoin" default-fetch="true" column="PBVOTOIN" jdbc-type="INTEGER"/> <field-descriptor name="pbvotofi" default-fetch="true" column="PBVOTOFI" jdbc-type="INTEGER"/> <field-descriptor name="pbricore" default-fetch="true" column="PBRICORE" jdbc-type="VARCHAR"/> <field-descriptor name="pblimore" default-fetch="true" column="PBLIMORE" jdbc-type="SMALLINT"/> <field-descriptor name="pboresim" default-fetch="true" column="PBORESIM" jdbc-type="VARCHAR"/> <field-descriptor name="pbprogra" default-fetch="true" column="PBPROGRA" jdbc-type="CHAR"/> <field-descriptor name="pbrimimp" default-fetch="true" column="PBRIMIMP" jdbc-type="VARCHAR"/> <field-descriptor name="pbetaini" default-fetch="true" column="PBETAINI" jdbc-type="SMALLINT"/> <field-descriptor name="pbetafin" default-fetch="true" column="PBETAFIN" jdbc-type="SMALLINT"/> <field-descriptor name="pbassstu" default-fetch="true" column="PBASSSTU" jdbc-type="VARCHAR"/> <field-descriptor name="pbnuasdl" default-fetch="true" column="PBNUASDL" jdbc-type="SMALLINT"/> <field-descriptor name="pbnuasll" default-fetch="true" column="PBNUASLL" jdbc-type="SMALLINT"/> <field-descriptor name="pbdtinco" default-fetch="true" column="PBDTINCO" jdbc-type="DATE" conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion"/> <field-descriptor name="pbdtfico" default-fetch="true" column="PBDTFICO" jdbc-type="DATE" conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlDateFieldConversion"/> <field-descriptor name="pbconreg" default-fetch="true" column="PBCONREG" jdbc-type="VARCHAR"/> <field-descriptor name="pbtidata" default-fetch="true" column="PBTIDATA" jdbc-type="VARCHAR"/> <field-descriptor name="pbannota" default-fetch="true" column="PBANNOTA" jdbc-type="CHAR"/> <field-descriptor name="pbdescr1" default-fetch="true" column="PBDESCR1" jdbc-type="CHAR"/> <field-descriptor name="pbdescr2" default-fetch="true" column="PBDESCR2" jdbc-type="CHAR"/> <field-descriptor name="pbdescr3" default-fetch="true" column="PBDESCR3" jdbc-type="CHAR"/> <field-descriptor name="pbdescr4" default-fetch="true" column="PBDESCR4" jdbc-type="CHAR"/> <field-descriptor name="pbumisu1" default-fetch="true" column="PBUMISU1" jdbc-type="CHAR"/> <field-descriptor name="pbumisu2" default-fetch="true" column="PBUMISU2" jdbc-type="CHAR"/> <field-descriptor name="pbumisu3" default-fetch="true" column="PBUMISU3" jdbc-type="CHAR"/> <field-descriptor name="pbumisu4" default-fetch="true" column="PBUMISU4" jdbc-type="CHAR"/> <field-descriptor name="pbformul" default-fetch="true" column="PBFORMUL" jdbc-type="VARCHAR"/> <field-descriptor name="pbnummes" default-fetch="true" column="PBNUMMES" jdbc-type="SMALLINT"/> <field-descriptor name="pbtipolo" default-fetch="true" column="PBTIPOLO" jdbc-type="CHAR"/> <field-descriptor name="pbassfis" default-fetch="true" column="PBASSFIS" jdbc-type="SMALLINT"/> <field-descriptor name="pbcodass" primarykey="true" default-fetch="true" column="PBCODASS" jdbc-type="VARCHAR"/> <collection-descriptor name="docassisteList" element-class-ref="w4b.com.cassagest.db.Docassiste" auto-update="true" auto-delete="true" proxy="false" auto-retrieve="false">
           <inverse-foreignkey field-ref="dbcodass"/>
       </collection-descriptor>
<collection-descriptor name="regassisteList" element-class-ref="w4b.com.cassagest.db.Regassiste" auto-update="true" auto-delete="true" proxy="false" auto-retrieve="false">
           <inverse-foreignkey field-ref="rbcodass"/>
       </collection-descriptor>
   </class-descriptor>

---------------------------------------------------------------------------------------------------------------------------------------

PassisteDAO

package w4b.com.cassagest.dao;

import javax.jdo.PersistenceManager;

import org.apache.ojb.broker.PersistenceBroker;
import org.apache.ojb.broker.PersistenceBrokerFactory;
import org.apache.ojb.broker.query.Query;
import org.apache.ojb.broker.query.QueryByIdentity;
import org.apache.ojb.broker.util.ObjectModificationDefaultImpl;

import w4b.com.cassagest.db.Passiste;


public class PassisteDAO{
public void retrieve(Passiste bean, JDO pmf) {

PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker(); Query query = new QueryByIdentity(bean); Passiste result = (Passiste) broker.getObjectByQuery(query);

broker.retrieveAllReferences(result); copyData(result,bean); broker.retrieveAllReferences(bean); broker.close();
   }

public void insert(Passiste bean, JDO pmf) { PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
       broker.beginTransaction();
       broker.store(bean,ObjectModificationDefaultImpl.INSERT );
       broker.commitTransaction();
       broker.close();
   }

   public void update(Passiste bean, JDO pmf) {
PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
       Query query = new QueryByIdentity(bean);
       Passiste result = (Passiste) broker.getObjectByQuery(query);
copyData(bean, result); broker.beginTransaction(); broker.store(result,ObjectModificationDefaultImpl.UPDATE);
       broker.store(result.getDocassisteList());
broker.commitTransaction(); broker.close();
    }
public void remove(Passiste bean, PersistenceManager pmf) { PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
       Query query = new QueryByIdentity(bean);
       broker.deleteByQuery(query);
       broker.close();
   }
public void copyData(Passiste from, Passiste to){ to.setPbprogre(from.getPbprogre()); to.setPbcodass(from.getPbcodass());
       to.setPbdtinval(from.getPbdtinval());
       to.setPbdtfival(from.getPbdtfival());
       to.setPbdescri(from.getPbdescri());
       to.setPbgglimd(from.getPbgglimd());
       to.setPbdtlimd(from.getPbdtlimd());
       to.setPbdtlavf(from.getPbdtlavf());
       to.setPbnumean(from.getPbnumean());
       to.setPbfamili(from.getPbfamili());
       to.setPbachias(from.getPbachias());
       to.setPbunicae(from.getPbunicae());
       to.setPbpercen(from.getPbpercen());
       to.setPbricvot(from.getPbricvot());
       to.setPbimpoun(from.getPbimpoun());
       to.setPbimpmax(from.getPbimpmax());
       to.setPbvotoin(from.getPbvotoin());
       to.setPbvotofi(from.getPbvotofi());
       to.setPbricore(from.getPbricore());
       to.setPblimore(from.getPblimore());
       to.setPboresim(from.getPboresim());
       to.setPbprogra(from.getPbprogra());
       to.setPbrimimp(from.getPbrimimp());
       to.setPbetaini(from.getPbetaini());
       to.setPbetafin(from.getPbetafin());
       to.setPbassstu(from.getPbassstu());
       to.setPbnuasdl(from.getPbnuasdl());
       to.setPbnuasll(from.getPbnuasll());
       to.setPbdtinco(from.getPbdtinco());
       to.setPbdtfico(from.getPbdtfico());
       to.setPbconreg(from.getPbconreg());
       to.setPbtidata(from.getPbtidata());
       to.setPbannota(from.getPbannota());
       to.setPbdescr1(from.getPbdescr1());
       to.setPbdescr2(from.getPbdescr2());
       to.setPbdescr3(from.getPbdescr3());
       to.setPbdescr4(from.getPbdescr4());
       to.setPbumisu1(from.getPbumisu1());
       to.setPbumisu2(from.getPbumisu2());
       to.setPbumisu3(from.getPbumisu3());
       to.setPbumisu4(from.getPbumisu4());
       to.setPbformul(from.getPbformul());
       to.setPbnummes(from.getPbnummes());
       to.setPbtipolo(from.getPbtipolo());
to.setPbassfis(from.getPbassfis()); to.setDocassisteList(from.getDocassisteList());
       to.setRegassisteList(from.getRegassisteList());
} }

-------------------------------------------------------------------------------------------

Passiste model

<?xml version="1.0" encoding="ISO-8859-1" ?>
<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"; xmlns:label="http://w4b.it/cocoon/label/"; xmlns:xsp="http://apache.org/xsp"; xmlns:i18n="http://apache.org/cocoon/i18n/2.1";>
<fd:widgets>
 <fd:output required="false" id="pbprogre" state="invisible">
   <fd:label><label:text>Progressivo</label:text></fd:label>
   <fd:datatype base="integer">
 </fd:datatype>
 </fd:output>

<fd:field required="false" id="pbcodass">
<fd:label><label:text>Codice Assistenza</label:text></fd:label>
 <fd:datatype base="string" />
 </fd:field>

<fd:field required="false" id="pbdtinval">
<fd:label>
 <label:text>Data inizio validità</label:text>
 </fd:label>
<fd:datatype base="date">
<fd:convertor>
<fd:patterns>
 <fd:pattern>dd/MM/yyyy</fd:pattern>
 </fd:patterns>
 </fd:convertor>
 </fd:datatype>
 </fd:field>

.
.
.
.
.
.
<fd:field required="true" id="pbassfis">
<fd:label>
 <label:text>Assoggettamento Fiscale</label:text>
 </fd:label>
<fd:datatype base="integer">
<fd:convertor type="formatting" variant="integer">
   <fd:patterns>
     <fd:pattern>##</fd:pattern>
   </fd:patterns>-->
 </fd:convertor>-->
</fd:datatype> <fd:selection-list src="cocoon://cforms/selectionLists/AssoggettamentoFiscale"/>
 </fd:field>



 <fd:repeater id="Docassiste">
     <fd:widgets>
         <fd:field required="false" id="dbprogre">
             <fd:label><label:text>Progressivo</label:text></fd:label>
             <fd:datatype base="integer">
             </fd:datatype>
           </fd:field>

         <fd:field id="dbcodass">
             <fd:label><label:text>Tipo assistenza</label:text></fd:label>
             <fd:datatype base="string"/>
         </fd:field>

<fd:field required="true" id="dbdocume"><fd:label><label:text>Documento richiesto</label:text></fd:label><fd:datatype base="integer"><fd:convertor variant="number"><fd:patterns><fd:pattern>########</fd:pattern></fd:patterns></fd:convertor></fd:datatype></fd:field>

<fd:field required="true" id="dbobblig"><fd:label><label:text>Obbligatorio</label:text></fd:label><fd:datatype base="string"/> <fd:selection-list src="cocoon://cforms/selectionLists/BooleanSN"/>
         </fd:field>

<fd:field required="false" id="dbannota"><fd:label><label:text>Annotazioni</label:text></fd:label><fd:datatype base="string"/></fd:field>

         <fd:booleanfield id="select">
             <fd:label>Select</fd:label>
         </fd:booleanfield>
   </fd:widgets>

 </fd:repeater>

 <fd:repeater-action id="addchild" command="add-row" repeater="Docassiste">
     <fd:label>Aggiungi documento necessario</fd:label>
 </fd:repeater-action>

<fd:repeater-action id="removechild" command="delete-rows" repeater="Docassiste" select="select">
     <fd:label>Elimina documento necessario</fd:label>
   </fd:repeater-action>

 </fd:widgets>
 </fd:form>
---------------------------------------------------------------------------------------------------------

Passiste binding

<?xml version="1.0" encoding="ISO-8859-1" ?>
<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding"; xmlns:fd="http://apache.org/cocoon/forms/1.0#definition"; path="/">
 <fb:value direction="both" id="pbprogre" path="pbprogre" />
 <fb:value direction="both" id="pbcodass" path="pbcodass" />
 <fb:value direction="both" id="pbdtinval" path="pbdtinval" />
 <fb:value direction="both" id="pbdtfival" path="pbdtfival" />
 <fb:value direction="both" id="pbdescri" path="pbdescri" />
 <fb:value direction="both" id="pbgglimd" path="pbgglimd" />
 <fb:value direction="both" id="pbdtlimd" path="pbdtlimd" />
 <fb:value direction="both" id="pbdtlavf" path="pbdtlavf" />
 <fb:value direction="both" id="pbnumean" path="pbnumean" />
 <fb:value direction="both" id="pbfamili" path="pbfamili" />
 <fb:value direction="both" id="pbachias" path="pbachias" />
 <fb:value direction="both" id="pbunicae" path="pbunicae" />
 <fb:value direction="both" id="pbpercen" path="pbpercen" />
 <fb:value direction="both" id="pbricvot" path="pbricvot" />
 <fb:value direction="both" id="pbimpoun" path="pbimpoun" />
 <fb:value direction="both" id="pbimpmax" path="pbimpmax" />
 <fb:value direction="both" id="pbvotoin" path="pbvotoin" />
 <fb:value direction="both" id="pbvotofi" path="pbvotofi" />
 <fb:value direction="both" id="pbricore" path="pbricore" />
 <fb:value direction="both" id="pblimore" path="pblimore" />
 <fb:value direction="both" id="pboresim" path="pboresim" />
 <fb:value direction="both" id="pbprogra" path="pbprogra" />
 <fb:value direction="both" id="pbrimimp" path="pbrimimp" />
 <fb:value direction="both" id="pbetaini" path="pbetaini" />
 <fb:value direction="both" id="pbetafin" path="pbetafin" />
 <fb:value direction="both" id="pbassstu" path="pbassstu" />
 <fb:value direction="both" id="pbnuasdl" path="pbnuasdl" />
 <fb:value direction="both" id="pbnuasll" path="pbnuasll" />
 <fb:value direction="both" id="pbdtinco" path="pbdtinco" />
 <fb:value direction="both" id="pbdtfico" path="pbdtfico" />
 <fb:value direction="both" id="pbconreg" path="pbconreg" />
 <fb:value direction="both" id="pbtidata" path="pbtidata" />
 <fb:value direction="both" id="pbannota" path="pbannota" />
 <fb:value direction="both" id="pbdescr1" path="pbdescr1" />
 <fb:value direction="both" id="pbdescr2" path="pbdescr2" />
 <fb:value direction="both" id="pbdescr3" path="pbdescr3" />
 <fb:value direction="both" id="pbdescr4" path="pbdescr4" />
 <fb:value direction="both" id="pbumisu1" path="pbumisu1" />
 <fb:value direction="both" id="pbumisu2" path="pbumisu2" />
 <fb:value direction="both" id="pbumisu3" path="pbumisu3" />
 <fb:value direction="both" id="pbumisu4" path="pbumisu4" />
 <fb:value direction="both" id="pbformul" path="pbformul" />
 <fb:value direction="both" id="pbnummes" path="pbnummes" />
<fb:value direction="both" id="pbtipolo" path="pbtipolo" /> <fb:javascript id="pbassfis" path="pbassfis"> <fb:load-form>
       var appValue = jxpathPointer.getValue();
       if (appValue != null) {
          var formValue = new java.lang.Integer(appValue);
          widget.setValue(formValue);
       }
     </fb:load-form>
<fb:save-form> var formValue = widget.getValue();
       if (formValue != null) {
           var appValue = new java.lang.Short(formValue);
           jxpathPointer.setValue(appValue);
       }
     </fb:save-form>
   </fb:javascript>


 <fb:repeater id="Docassiste"
              parent-path="."
              row-path="docassisteList">
  <fb:identity>
     <fb:value id="dbprogre" path="@dbprogre"/>
</fb:identity> <fb:on-bind> <fb:value id="dbcodass" path="dbcodass" direction="both"/> <fb:value id="dbdocume" path="dbdocume" direction="both"/> <fb:value id="dbobblig" path="dbobblig" direction="both"/>
     <fb:value id="dbannota" path="dbannota" direction="both"/>
   </fb:on-bind>

   <fb:unique-row>
     <fb:unique-field id="dbprogre" path="@dbprogre"/>
</fb:unique-row>
   <fb:on-insert-row>
     <fb:insert-bean
       classname="w4b.com.cassagest.db.Docassiste"
       addmethod="addDocassiste"/>
   </fb:on-insert-row>
<fb:on-delete-row>
       <fb:delete-node />
</fb:on-delete-row> </fb:repeater>
 </fb:context>

------------------------------------------------------------------------------

Passiste template   (repeater section)


<?xml version="1.0"?>
<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template"; xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"; xmlns:jx="http://apache.org/cocoon/templates/jx/1.0";>

<ft:form-template action="continue?${request.getQueryString()}" method="POST" ajax="true">
               <ft:continuation-id/>

               <ft:repeater id="Docassiste">
               <table border="1">
                   <tr>
<!--<th><ft:repeater-widget-label widget-id="dbprogre"/></th>--> <th><ft:repeater-widget-label widget-id="dbdocume"/></th> <th><ft:repeater-widget-label widget-id="dbobblig"/></th> <th><ft:repeater-widget-label widget-id="dbannota"/></th> <!--<th><ft:repeater-widget-label widget-id="dbcodass"/></th>--> <th><ft:repeater-widget-label widget-id="select"/></th>
                   </tr>

                           <ft:repeater-rows>
                               <tr>
                                   <td>
                                       <ft:widget id="dbprogre" >
                                          <ft:styling type="hidden"/>
</ft:widget> </td>
                                   <td><ft:widget id="dbdocume"/></td>
                                   <td><ft:widget id="dbobblig"/></td>
                                   <td><ft:widget id="dbannota"/></td>
                                   <td>
                                       <ft:widget id="dbcodass" >
                                          <ft:styling type="hidden"/>
</ft:widget> </td><td><ft:widget id="select"/></td>
                               </tr>
                           </ft:repeater-rows>

               </table>
           </ft:repeater>
           <table>
               <tr>
<td>
                       <ft:widget id="addchild"/>
                           <ft:widget id="removechild"/>

                           <!--</jx:if>-->
                   </td>
                   </tr>
               </table>

<input type="submit" name="Salva" value="Salva" class="submit" />
               </ft:form-template>

</page>




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]