cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hugo Burm" <>
Subject RE: persisting re-arranged repeater-rows
Date Wed, 26 Nov 2003 19:05:58 GMT
Hello Jeremy,

Some random remarks:

It should work just as you described. Hibernate must create the id. The
example from the Wiki is working as expected (tested from CVS about two
weeks ago) and is almost identical to your album-resources relation.

So I tried to spot the differences between your mapping and the example on
the Wiki:
- you are using "lazy=true" in the <list> (which is a good thing)
- your are using "native", I am using "identity" for the <generator>
- I have an 'unsaved-value="0"' attribute to the id of your Resource
mapping. (try this one!)
- I guess you are closing the Hibernate session before you do the showForm
and create a new session once the form is submitted.

May be this give you some clues where to look for. One other problem I
encoutered was the difference between integer and long. I assumed that all
frameworks involved should solve this for me. I was wrong.

I dived a little bit into the Woody internals. When a row is added to the
repeater the saveFormToModel method in InsertBeanJXPathBinding class is
called. This method executes the "addMethod" that was defined in the
<wb:insert-bean> binding. (you are talking about "add-row" in the model
definition, I am talking about "insert-bean" in the bean binding. Somtimes I
think this Woody beast is too complicated for me).

When a row is removed from the repeater and removed by jxpath, all keys of
your Resource bean will be set to null. So it looks like the record is
removed. But it will still be there in your database, living as a zombie. So
may be we need some "deleteMethod" executed by a DeleteBeanJXPathBinding.


> -----Original Message-----
> From: Jeremy Quinn []
> Sent: Wednesday, November 26, 2003 12:54 PM
> To:
> Subject: Re: persisting re-arranged repeater-rows
> On 25 Nov 2003, at 13:44, Hugo Burm wrote:
> > I guess one of the problems will be sorting after you added a new item,
> > because the new item does not yet have an id in Woody.
> >
> Yeah ... next problem ....
> I added this to my form model :
>      <wd:repeater-action id="addresource" action-command="add-row"
> repeater="resources">
>        <wd:label><i18n:text
> i18n:catalogue="local">label.add.resource</i18n:text></wd:label>
>      </wd:repeater-action>
> When the button is clicked, a new repeater-row appears.
> When the data is filled-in and the form is saved, the new row does not
> get copied into the Bean, because I suspect as you said, it has no
> 'unique-id'.
> It is not my job to give it an 'id' it is Hibernate's business !!
> Hibernate will give it an appropriate 'id' when it is persisted.
> If Hibernate finds a synthetic 'id' in there it will freak out ....
> I cannot persist it in an event-handler in the add-row command because
> it has no data and the database will reject it.
> Any suggestions as to how to move forward on this?
> Thanks
> regards Jeremy

View raw message