cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Quinn <jer...@media.demon.co.uk>
Subject Re: persisting re-arranged repeater-rows
Date Wed, 26 Nov 2003 20:24:33 GMT

On 26 Nov 2003, at 19:05, Hugo Burm wrote:

> Hello Jeremy,
>
> Some random remarks:

Many thanks

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

Thanks, I'll have another look ....

> 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 am using PostgreSQL, I believe it needs 'native'.

> - I have an 'unsaved-value="0"' attribute to the id of your Resource
> mapping. (try this one!)

No Good ;)
AFAIU, showForm() does not exit during the Add.
The User could add several Rows before such time as they exit the 
showForm() function by hitting 'save'.

What I am thinking of looking into, is generating synthetic ids on my 
listed Beans, purely to guarantee that Woody can always have a 
'unique-id' for the repeater. But I do not know if this approach is 
possible yet.

> - I guess you are closing the Hibernate session before you do the 
> showForm
> and create a new session once the form is submitted.

Yes, but only once showForm() has exited (which is not quite the same 
thing)

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

OK

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

Hmmm, this is something I need to check .... thanks

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

Nice idea.
Or as Bruno suggested (on Cocoon Users) write an event handler for the 
button ....

> Hugo

Many thanks for your feedback.

regards Jeremy

>
>> -----Original Message-----
>> From: Jeremy Quinn [mailto:jeremy@media.demon.co.uk]
>> Sent: Wednesday, November 26, 2003 12:54 PM
>> To: dev@cocoon.apache.org
>> 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
>>
>

Mime
View raw message