Hi, Just a quick response.
What you describe here are two entities: rooms and persons. It is much more common sense to treat them separately, i.e. a list for editing persons (just a repeater) and a list for editing rooms (simple list?) and finally, maybe a doubleList for adding persons to a room. HTH. Bye, Helma > -----Original Message----- > From: Ben Pope [mailto:[EMAIL PROTECTED] > Sent: Sunday, 13 March 2005 18:12 > To: [email protected] > Subject: CForms Binding - Cross Referenced Data (duplicate of > post on users) > > > Hi, > > First of, sorry for the post here, but I've asked a few times > on users and > not had this solved, so I'm gonna cross my fingers and post here: > > This is something I've been struggling with, on and off, for > some time now. > > Assume I have some data as follows: > > <project> > <people> > <person id="0"> > <name>Me</name> > </person> > <person id="1"> > <name>You</name> > </person> > <person id="2"> > <name>Him</name> > </person> > </people> > <rooms> > <room id="0"> > <name>Lounge</name> > <person idref="0"/> > <person idref="1"/> > </room> > <room id="1"> > <name>Kitchen</name> > <person idref="2"/> > </room> > </rooms> > </project> > > That describes a list of people which are in a particular > room, so Me and > You are in the Lounge and Him is in the Kitchen. > > I want to have a form that displays, for a given room, a list > of the people > in it. > > A repeater is obviously the first choice, but there are a few > counter-intuitive thingsd going on: > > I need to be able to modify the name of the person. Simply > running the > repeater over the rooms is not enough. > > Adding a row needs to add an rooms/room/person with an idref > - I'll then use > client side javascript and XMLHTTP to allow the user to > select a person (by > id) to fit in the space, as all the people are predefined. I > do not want to > have the repeater add /people/persons. > > I've toyed with a few ideas: > > id is passed in as a parameter, and this code is actually in > a stylesheet - > but ignore that for now. > > <fb:repeater id="people" parent-path="/project/rooms/[EMAIL PROTECTED]" > row-path="/project/people/[EMAIL PROTECTED]/project/rooms/[EMAIL PROTECTED] > $id}]/person/@ > idref]"> > > This "solution" has the result of being perfect for load. > However, when I > save it, it breaks, because I can't have an xpath predicate. > So what do I > set the row-path-insert to? > > If I set row-path-insert="/project/people/person" and bind > the id (which is > fb:identity) in both directions, /project/people/ ends up correct, but > /project/rooms/room/ doesn't get updated. > > I've tried > <fb:on-insert-row> > <fb:context path="/project/rooms/[EMAIL PROTECTED]'0']"> > <fb:insert-node> <person idref="5"/> > </fb:insert-node> > > But then I get a new node in both /rooms/[EMAIL PROTECTED]'0']/ which > is correct, > and another node created in /project/people/ which is the > usual binding for > person and is a copy of the existing one. This doesn't seem > correct to me. > > Hmm, I've had a little play with fb:javascript but I don't > know what I'm > doing... Ideally I would remove all the > /rooms/[EMAIL PROTECTED]'x']/person fields > and repopulate with the list of ids in the repeater. I can't > seem to work > out the correct APIs, it always says that such and such > method doesn't exist > - can anybody point me in the right direction? > > I've toyed with the idea of having two repeaters, and > updating one from the > other but it sounds like a recipe for disaster. > > Another idea was to have a play around with it in flow, but I > suspect I'd > end up with exactly the same problems I have using > fb:javascript, with the > disadvantage of distributing the binding code. > > Any help is much appreciated, I'm confused by the number of > options and > multitude of interfaces. > > I can't be the only person working with cross-referenced > data! I'm either > missing something or the repeater just doesn't understand > this construct - I > wonder if Sylvain has any ideas on this. > > I also started writing my own Repeater (well I copied the > existing one, > renamed it, changed some of it's parameters and managed to > get Cforms to use > it), but running through with eclipse in debug mode doesn't > really throw any > light on the subject - it's all too confusing for me. > > Heeeelp! > > Ben >
