cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hugo Burm" <hu...@xs4all.nl>
Subject RE: Woody, maps, and repeaters
Date Sat, 23 Aug 2003 15:40:38 GMT


> Marc Portier wrote:
>
>
> Hugo Burm wrote:
> > Hello Marc,
> >
>
> sorry for the late reply...
>
> > Ok. Let me explain. Maps are sometimes much more convenient than Lists
> > (let's skip a discussion on that one). So I have two classes:
> <SKIP/>
>
> Well, for what its worth the not to have discussion is probably
> not on LIST vs MAP but MAP vs SET :-)
>
> I'ld personally would have tackled this with a HashSet of
> contacts and adding the appropriate hashcode() and equals()
> methods to the HContact so its very own id would serve as the
> fast lookup in the Set...
>
> (but it doesn't really change much the real issue here)
>
> > What I want to do is: create a Map of contacts in HForm2Bean and access
> > these contacts with a key "id".
> > This key is also stored in one of the fields of HContact (id). The field
> > that is the key, should be one of the configuration parameters
> of the Woody
> > repeater.
>
> yep.
>
> > This solves your question "which key to use?".
>
> not really, it doesn't solve the question on the way back, unless
> you expect the id's to be edited by hand?
>
> (which would surely require another RepeaterBinding implementation)
>



I tried to ommit the persistence topic, but many of the issues above have to
do with the Hibernate framework I am using. E.g. the id is generated by
Hibernate. This works OK for the list implementation in Woody. The Woody
framework detects a contact that is inserted because its id is null. Then,
Hibernate generates the id when saving the contact to hard disk.

About lists, maps, and sets: Hibernate has four mappings: the three I just
mentioned, plus something called a "bag". So people like me will keep on
asking for repeaters for these three types. JDO 2.0 builds on Hibernate. So
I will not be the last one asking for this.


> > file "binding_example.js" in such a way that a bean and a
> number of contacts
> > are created; the editing is skipped; and we go directly to your pipeline
> > "form2bean-success-pipeline", the form2_jx.xml form is called.
> This contains
> > the loop:
> >       <jx:forEach var="item" items="${form2bean.contacts}">
> >         <tr>
> >           <td>${item.id}</td>
> >           <td>${item.firstName}</td>
> >           <td>${item.lastName}</td>
> > 					<skip/>
> >         </tr>
> >       </jx:forEach>
> >
> > This loops shows the correct results when I use a map instead of a list!
>
> hm, my turn to be not convinced: above uses the ${..} expressions
> inside jx and not the #{..}
>
> ${..} in jx are evaluated by jexl
> #{..} are covered by jxpath
>
> so we're looking at a horse of an entirely different color here.
>



OK, may be I had too much sunshine the last couple of weeks. I did a post
myself about the difference between # and $ a few weeks ago which covered
exactly this problem:
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=106050576128633&w=2
I checked the JXPath docs and your explanation appears to be correct. Sorry.


>
>
> Back to your issue: how to edit these beans with Woody/Binding?
>
> I would need some more time to get into it more deeply, so I
> wouldn't mind if somebody with more current slack hacks this up
> ans shares this
>
> Hugo, how urgent is this for you?
>
> AFAICS this needs a different RepeaterBinding of some sort that
> is not that much different to the existing one, just that
>
>


I hacked the Woody RepeaterBinding myself and solved my own urgent problem.
Listing a map of contacts is working. Updating is working. Adding and
deleting contacts is something I don't need at the moment (off course my
real world problem has nothing to do with this form2bean and contact
classes), but I will try to add this, and send the results to you.

Thanks.


Hugo Burm


Mime
View raw message