cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leszek Gawron <>
Subject CForms and repeater id - a problematic case study
Date Mon, 13 Sep 2004 14:51:20 GMT
There is one thing that bugs me a lot when dealing with cforms and that is: 
the need for unique repeater id.

Does anyone have a nice solution for something like this:
A form is bound to and O/R managed bean:

class Net {
	private String name;

	// elements of class Depot
	Set depots;

depots could be shown using a repeater like this:
<fd:repeater id="depots">
         <fd:output id="id">
             <fd:datatype base="long"/>
         <fd:field id="name">
             <fd:datatype base="string"/>
         <fd:submit id="edit-depot" action-command="-">

Now you want to add a depot somehow. That's easy - simple fd:submit with 
validate = false. Problem is you have to assign a unique id but you need the 
id to be null so the bean will be persisted as new. You cannot use repeater 
action as this would insert an empty Depot bean into the collection and mess 
everything up.

So you have to:
1. assign a temporal id somehow unique from all existing
2. then remove it (nullify) after and before the bean is persisted

it got really bad:
1. the id has to be somehow different from the "persistent" one ( <0 ? )
2. if you edit a deeper structure nullifying the temporal ids gets really ugly.

Finally: you cannot use simple repeater which will delete and overwrite whole 
collection as this would break database constraints.

Please comment.
Leszek Gawron                            

View raw message