You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Alessandro Vincelli <a....@w4b.it> on 2006/02/08 15:08:47 UTC

CFORM - repeater , add-row on OJB collection

I have a this simple form with repeater:


The flowscript invoke dao.getAllRows, and pass to form/bionding a Colection:

------------ BEGIN flowscript---------------------------

Elenco = dao.getAllRows(manager);
form.load(Elenco);
......
form.save(Elenco);
------------  END flowscript---------------------------


------------ BEGIN OJB METHOD---------------------------

public Collection getAllRows(PersistenceManager pm) {
	PersistenceBroker broker = 
PersistenceBrokerFactory.defaultPersistenceBroker();
		Criteria crit = new org.apache.ojb.broker.query.Criteria();
		QueryByCriteria q = new QueryByCriteria(Docuassist.class, crit);
		Collection objects = (Collection)broker.getCollectionByQuery(q);
	
		q.addOrderByAscending("dgprogre");
			
		broker.close();
		return objects;
}
	
------------ END OJB METHOD---------------------------


When I modify 1 or more bean in the collection and in flowscript  call

form.save(Elenco);
....

I save correctly the bean in database.


The problem occur when i try to insert new row

I receive this error on:
form.save(Elenco);


java.lang.NoSuchMethodException: 
org.apache.ojb.broker.util.collections.RemovalAwareCollection.add(w4b.com.cassagest.db.Docuassist)


in my binding definition I have this:
         <fb:on-insert-row>
             <fb:insert-bean classname="w4b.com.cassagest.db.Docuassist" 
addmethod="add"/>
         </fb:on-insert-row>


How Can I add object to a Collection from  OJB?


Thanks in advance, Alessandro





_____________________________________________________________________________
MODEL:

<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" 
xmlns:label="http://w4b.it/cocoon/label/" 
xmlns:i18n="http://apache.org/cocoon/i18n/2.1">

     <fd:widgets>
         <fd:repeater id="Docuassist">
             <fd:label>Repeater di docuassist</fd:label>
             <fd:widgets>

                 <fd:field id="dgprogre">
                     <fd:label>Progressivo</fd:label>
                     <fd:datatype base="integer"/>
                 </fd:field>

                 <fd:field id="dgdescri">
                     <fd:label>Descrizione ridotta</fd:label>
                     <fd:datatype base="string">
                     </fd:datatype>
                 </fd:field>

                 <fd:field id="dgdescre">
                     <fd:label>Descrizione estesa</fd:label>
                     <fd:datatype base="string">
                     </fd:datatype>
                 </fd:field>

                 <fd:row-action id="up" command="move-up"/>
                 <fd:row-action id="down" command="move-down"/>

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

         <fd:repeater-action id="addRow" command="add-row" 
repeater="Docuassist">
             <fd:label>Aggiungi riga</fd:label>
         </fd:repeater-action>

         <fd:repeater-action id="removeRow" command="delete-rows" 
repeater="Docuassist" select="select">
             <fd:label>Rimuovi le righe selezionate</fd:label>
         </fd:repeater-action>
     </fd:widgets>

</fd:form>
_________________________________________________________________________________________________
BINDING


<fb:repeater id="Docuassist" parent-path="." row-path=".">
         <fb:identity>
             <fb:value id="dgprogre" path="dgprogre"/>
         </fb:identity>
         <fb:on-bind>
             <fb:value id="dgdescri" path="dgdescri"/>
             <fb:value id="dgdescre" path="dgdescre"/>
         </fb:on-bind>

         <fb:unique-row>
             <fb:unique-field id="dgprogre" path="dgprogre"/>
         </fb:unique-row>

         <fb:on-insert-row>
             <fb:insert-bean classname="w4b.com.cassagest.db.Docuassist" 
addmethod="add"/>
         </fb:on-insert-row>
     </fb:repeater>





_______________________________________________________________________________________________________
STACKTRACE



Message: 
org.apache.ojb.broker.util.collections.RemovalAwareCollection.add(w4b.com.cassagest.db.Docuassist)

Description: org.apache.cocoon.ProcessingException: Error calling 
continuation at 
resource://org/apache/cocoon/forms/flow/javascript/Form.js:228:-1 at 
file:/var/webapps/cassagest/cforms/cforms/flow/cattura.js:175:-1 at 
<map:call> - file:/var/webapps/cassagest/cforms/sitemap.xmap:356:82 at 
<map:mount> - file:/var/webapps/cassagest/sitemap.xmap:727:83

Sender: org.apache.cocoon.servlet.CocoonServlet

Source: Cocoon Servlet

Request URI

cforms/continue

cause

java.lang.NoSuchMethodException: 
org.apache.ojb.broker.util.collections.RemovalAwareCollection.add(w4b.com.cassagest.db.Docuassist)

request-uri

/cassagest/cforms/continue

full exception chain stacktrace

org.apache.cocoon.ProcessingException: Error calling continuation
	at resource://org/apache/cocoon/forms/flow/javascript/Form.js:228:-1
	at file:/var/webapps/cassagest/cforms/cforms/flow/cattura.js:175:-1
	at <map:call> - file:/var/webapps/cassagest/cforms/sitemap.xmap:356:82
	at <map:mount> - file:/var/webapps/cassagest/sitemap.xmap:727:83
	at 
org.apache.cocoon.ProcessingException.throwLocated(ProcessingException.java:144)
	at 
org.apache.cocoon.components.flow.javascript.LocationTrackingDebugger.getException(LocationTrackingDebugger.java:132)
	at 
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.handleContinuation(FOM_JavaScriptInterpreter.java:856)
	at 
org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(CallFunctionNode.java:123)
	at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:46)
	at 
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130)
	at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:68)
	at 
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:142)
	at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:68)
	at 
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:92)
	at 
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:234)
	at 
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:176)
	at 
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:248)
	at 
org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(MountNode.java:117)
	at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:46)
	at 
org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:130)
	at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:68)
	at 
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:142)
	at 
org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:68)
	at 
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:92)
	at 
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:234)
	at 
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(ConcreteTreeProcessor.java:176)
	at 
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:248)
	at org.apache.cocoon.Cocoon.process(Cocoon.java:679)
	at org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1154)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
	at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
	at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at 
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
	at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
	at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
	at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at 
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
	at org.apache.catalina.core.StandardPipeline.invoke(Stand
-- 
-------------------------------
Alessandro Vincelli
W4B - web for business s.r.l.
Firenze
via Pellicceria 10 - 50123
E-mail: a.vincelli@w4b.it
tel: 055-2654270

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


Re: CFORM - repeater , add-row on OJB collection

Posted by Christoph Hermann <ch...@guschtel.de>.
Am Freitag, 10. Februar 2006 10:06 schrieb Alessandro Vincelli:

> I would want simply to work directly on one table with a repeater.  The
> table does not have to be connected to a father like in all the examples
> of the repeater.
> Hour I succeed to modify the table, but I do not succeed to add lines.
>
> The problem is in binding.
>
> I pass an ArrayList to a binding, when I invoke "add" method on insert row
> error:
> java.lang.NoSuchMethodException:
> com.sun.jdori.common.sco.ArrayList.add(w4b.com.cassagest.db.Docuassist)

> <fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" path=".">
>      <fb:repeater id="Docuassist" parent-path="." row-path=".">

I suppose the problem sits in these two lines.
Try to change the path-values in some way... (don't ask me how ;))

Christoph

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


Re: CFORM - repeater , add-row on OJB collection

Posted by Alessandro Vincelli <a....@w4b.it>.

I would want simply to work directly on one table with a repeater.  The 
table does not have to be connected to a father like in all the examples 
of the repeater.
Hour I succeed to modify the table, but I do not succeed to add lines.

The problem is in binding.

I pass an ArrayList to a binding, when I invoke "add" method on insert row
error:
java.lang.NoSuchMethodException: 
com.sun.jdori.common.sco.ArrayList.add(w4b.com.cassagest.db.Docuassist)

Thanks in advance,
This my simple binding,



<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding" path=".">
     <fb:repeater id="Docuassist" parent-path="." row-path=".">
         <fb:identity>
             <fb:value id="dgprogre" path="@dgprogre"/>
         </fb:identity>
         <fb:on-bind>
             <fb:value id="dgdescri" path="dgdescri"/>
             <fb:value id="dgdescre" path="dgdescre"/>
         </fb:on-bind>

         <fb:unique-row>
             <fb:unique-field id="dgprogre" path="@dgprogre"/>
         </fb:unique-row>

         <fb:on-insert-row>
             <fb:custom>
             </fb:custom>
             <fb:insert-bean classname="w4b.com.cassagest.db.Docuassist" 
addmethod="add"/>
         </fb:on-insert-row>
     </fb:repeater>
</fb:context>

-------------------------------
Alessandro Vincelli
W4B - web for business s.r.l.
Firenze
via Pellicceria 10 - 50123
E-mail: a.vincelli@w4b.it
tel: 055-2654270


Christoph Hermann ha scritto:
> Alessandro Vincelli schrieb:
> 
> Hi,
> 
> 
>>But the situation if different from the example.
>>I have form-repeater similar to exaple in the link, and work fine.
>>
>>In this situation I try to add Bean directly to a collection from OJB.
>>The collection is returned from OJB.
>>org.apache.ojb.broker.util.collections.RemovalAwareCollection
>>
>>The RemovalAwareCollection has
>>RemovalAwareCollection.add(java.lang.Object)
>>RemovalAwareCollection.ojbAdd(java.lang.Object)
>>
>>and in bind I use this method
>><fb:on-insert-row>
>>            <fb:insert-bean classname="w4b.com.cassagest.db.Docuassist"
>>addmethod="add"/>
>>        </fb:on-insert-row>
>>
>>But I have this problem:
>>
>>java.lang.NoSuchMethodException:
>>org.apache.ojb.broker.util.collections.RemovalAwareCollection.add(w4b.com.cassagest.db.Docuassist)
> 
> 
>>Any idea?
> 
> 
> If nothing else works, you can add it yourself in some javascript
> snippet in the corresponding event javascript-section.
> 
> Sorry, i don't know where your problem comes from.
> 
> Christoph
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 

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


Re: CFORM - repeater , add-row on OJB collection

Posted by Christoph Hermann <ch...@guschtel.de>.
Alessandro Vincelli schrieb:

Hi,

> But the situation if different from the example.
> I have form-repeater similar to exaple in the link, and work fine.
> 
> In this situation I try to add Bean directly to a collection from OJB.
> The collection is returned from OJB.
> org.apache.ojb.broker.util.collections.RemovalAwareCollection
> 
> The RemovalAwareCollection has
> RemovalAwareCollection.add(java.lang.Object)
> RemovalAwareCollection.ojbAdd(java.lang.Object)
> 
> and in bind I use this method
> <fb:on-insert-row>
>             <fb:insert-bean classname="w4b.com.cassagest.db.Docuassist"
> addmethod="add"/>
>         </fb:on-insert-row>
> 
> But I have this problem:
> 
> java.lang.NoSuchMethodException:
> org.apache.ojb.broker.util.collections.RemovalAwareCollection.add(w4b.com.cassagest.db.Docuassist)

> Any idea?

If nothing else works, you can add it yourself in some javascript
snippet in the corresponding event javascript-section.

Sorry, i don't know where your problem comes from.

Christoph

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


Re: CFORM - repeater , add-row on OJB collection

Posted by Alessandro Vincelli <a....@w4b.it>.
thanks,
But the situation if different from the example.
I have form-repeater similar to exaple in the link, and work fine.

In this situation I try to add Bean directly to a collection from OJB.
The collection is returned from OJB.
org.apache.ojb.broker.util.collections.RemovalAwareCollection

The RemovalAwareCollection has
RemovalAwareCollection.add(java.lang.Object)
RemovalAwareCollection.ojbAdd(java.lang.Object)

and in bind I use this method
<fb:on-insert-row>
             <fb:insert-bean classname="w4b.com.cassagest.db.Docuassist"
addmethod="add"/>
         </fb:on-insert-row>

But I have this problem:

java.lang.NoSuchMethodException:
org.apache.ojb.broker.util.collections.RemovalAwareCollection.add(w4b.com.cassagest.db.Docuassist)


Any idea?



-------------------------------
Alessandro Vincelli
W4B - web for business s.r.l.
Firenze
via Pellicceria 10 - 50123
E-mail: a.vincelli@w4b.it
tel: 055-2654270


Christoph Hermann ha scritto:
> Alessandro Vincelli schrieb:
> 
> 
>>The problem occur when i try to insert new row
>>
>>I receive this error on:
>>form.save(Elenco);
> 
> 
>>java.lang.NoSuchMethodException:
>>org.apache.ojb.broker.util.collections.RemovalAwareCollection.add(w4b.com.cassagest.db.Docuassist)
> 
> 
>>in my binding definition I have this:
>>        <fb:on-insert-row>
>>            <fb:insert-bean classname="w4b.com.cassagest.db.Docuassist"
>>addmethod="add"/>
>>        </fb:on-insert-row>
> 
> 
>>How Can I add object to a Collection from  OJB?
> 
> 
> This (forget about the jdo stuff):
> http://www.guschtel.de/HP5/linux/ojbjdo_dmton.php
> should get you started, you can specify a method in the binding.
> 
> HTH
> Christoph
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 

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


Re: CFORM - repeater , add-row on OJB collection

Posted by Christoph Hermann <ch...@guschtel.de>.
Alessandro Vincelli schrieb:

> The problem occur when i try to insert new row
> 
> I receive this error on:
> form.save(Elenco);

> java.lang.NoSuchMethodException:
> org.apache.ojb.broker.util.collections.RemovalAwareCollection.add(w4b.com.cassagest.db.Docuassist)

> in my binding definition I have this:
>         <fb:on-insert-row>
>             <fb:insert-bean classname="w4b.com.cassagest.db.Docuassist"
> addmethod="add"/>
>         </fb:on-insert-row>

> How Can I add object to a Collection from  OJB?

This (forget about the jdo stuff):
http://www.guschtel.de/HP5/linux/ojbjdo_dmton.php
should get you started, you can specify a method in the binding.

HTH
Christoph

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


Re: CFORM - repeater , add-row on OJB collection

Posted by Joerg Heinicke <jo...@gmx.de>.
On 08.02.2006 15:08, Alessandro Vincelli wrote:

> The problem occur when i try to insert new row
> 
> I receive this error on:
> form.save(Elenco);
> 
> 
> java.lang.NoSuchMethodException: 
> org.apache.ojb.broker.util.collections.RemovalAwareCollection.add(w4b.com.cassagest.db.Docuassist) 
> 
> in my binding definition I have this:
>         <fb:on-insert-row>
>             <fb:insert-bean classname="w4b.com.cassagest.db.Docuassist" 
> addmethod="add"/>
>         </fb:on-insert-row>
> 
> How Can I add object to a Collection from  OJB?

The insert is done by reflection. If you search for a method "add" with 
Docuassist.class as parameter while Collection has a method "add" with 
Object.class you will get the above exception as the parameters are not 
upcasted. This is why you probably can not add beans directly to 
collections, but I haven't tried it recently. I wrote an application 
based on OJB and CForms 1,5 years ago and did the binding with a 
delegating method:

binding:
<fb:on-insert-row>
   <fb:insert-bean classname="com.ewerk.erak.model.InterestRate"
                   addmethod="addInterestRate"/>
</fb:on-insert-row>

object:
public void addInterestRate(InterestRate interestRate) {
     getInterestRates().add(interestRate);
}

where getInterestRates() returns the collection, i.e. OJB's 
RemovalAwareCollection instance.

Jörg

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