cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Lowe <mel...@gmail.com>
Subject Re: CForms Binding - Cross Referenced Data (duplicate of post on users)
Date Sun, 13 Mar 2005 23:36:48 GMT
I dont think the dream team example covers nested repeaters.. I'll
have to suck it and see if this can be done.. this is something I've
done in the past with other frameworks and plain servlets and jsp.

Without having tried it yet, if it were the case that cocoon forms
cant deal with nested lists/rows then i guess trying to use aggreate
fields as child widgets would be worth a go. Pass the people as a
tokenized string and then use flow to convert to tokens in save-form.
During load-form or even on bind you could populate the aggregated
field.

I'd probably want my data xml strutured more like

<room>
 <person />
</room>

So the binder would know that there's a nested object inside room. 

I'll have a go when i get time, as i anticipate that this is the sort
of thing that crops up a lot. Hopefully nested repeaters are
supported.

Mark

On Sun, 13 Mar 2005 20:25:50 +0100, Linden H van der (MI)
<H.vanderLinden@mi.unimaas.nl> wrote:
> You could make a multipage form if necessary.
> 
> Also have a look at the samples in the forms block. I think the
> dreamteam sample and the dynamic repeater sample demonstrate what you
> are looking for.
> 
> HTH.
> 
> Bye, Helma
> 
> 
> > -----Original Message-----
> > From: Ben Pope [mailto:ben_pope@REMOVE_MEhotmail.com]
> > Sent: Sunday, 13 March 2005 20:22
> > To: dev@cocoon.apache.org
> > Subject: RE: CForms Binding - Cross Referenced Data
> > (duplicate of post on users)
> >
> >
> > Linden H van der (MI) wrote:
> > > 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.
> >
> > Quite possibly, but I'm recreating some paper forms and want
> > the user to be
> > able to enter the information as quicky as possible using my system.
> >
> > Essentially all the peoples names and ids are predefined
> > (there will no
> > doubt be a form to enter those people, too), but can be
> > modified at any
> > point.  More fields will be added to the people using this
> > form (lets say;
> > age, height, favourite colour).
> >
> > Unfortunately it has to be done this way.
> >
> > Thanks for your reply.
> >
> >
> > Does anybody know how I can use fb:javascript (or flow, if
> > not) to grab each
> > id specified in the repeater and replace people elements
> > inside of the room
> > with the appropriate idrefs?
> >
> > Cheers,
> >
> > Ben Pope
> >
> >
> >
> >
> >
> > > > -----Original Message-----
> > > > From: Ben Pope [mailto:ben_pope@REMOVE_MEhotmail.com]
> > > > Sent: Sunday, 13 March 2005 18:12
> > > > To: dev@cocoon.apache.org
> > > > 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/room[@id={$id}]"
> > > > row-path="/project/people/person[@id=/project/rooms/room[@id={
> > > > $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/room[@id='0']">
> > > >             <fb:insert-node>   <person idref="5"/>
> > > >       </fb:insert-node>
> > > >
> > > > But then I get a new node in both /rooms/room[@id='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/room[@id='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
> > > >
> > >
> >
>

Mime
View raw message