cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Gianni <s.gia...@thebug.it>
Subject Re: Bean Binding and Repeaters...
Date Fri, 12 May 2006 15:22:50 GMT
Hi Berin,

  *<?xml* version="1.0" encoding="UTF-8"*?>* *
  <fb:context* xmlns:fb="http://apache.org/cocoon/forms/1.0#binding"
path="/"*>* *
    <fb:repeater* id="terms" parent-path="." row-path="terms"*>* *
      <fb:value* id="id" path="termId"*/>* *
      <fb:value* id="term-name" path="term"*/>* *
      <fb:value* id="isHotTopic" path="isPostHT"*/>* *
      <fb:value* id="displayName" path="fullDesc"*/>* *
    </fb:repeater>* *
    <fb:repeater* id="hotTopics" parent-path="." row-path="hotTopics"*>* *
      <fb:value* id="id" path="termId"*/>*
       *<fb:value* id="displayName" path="fullDesc"*/>* *
    </fb:repeater>*
  *</fb:context>

First, in both repeaters you should specify that id is the identity
field. Without the identity field the repeater binding is not able to
find match a row with a bean in the list.

When the repeater receives all the request parameters, it takes the
terms.0.id (or any other identity field you specified, you can specify
more than one) and searches in the list for a bean having that termId.
If it finds it then execute the rest of the binding against it,
otherwise the row is marked as being a new row and a binding to create
the new row is searched. Since there isn't any, something is written in
the log file and that repeater row is discarded. But the most harmful
thing is that after doing all this, it searches for all the beans that
didn't matched any row in the repeater, and removes them from the list,
even if there is no explicity binding to remove them. While JXPath is
not able to add a new bean in a collection without an explicit binding
(since could not know which class instantiate), it's extremely able in
removing them :)

Second, we usually put the <fb:value> of a repeater inside an
<fb:on-bind>. Somewhere between 2.1.6 and 2.1.7 AFAIK fb:on-bind was
introduced and many repeaters didn't worked correctly if it's not there.

Third, the **<fb:value* id="isHotTopic" path="isPostHT"*/>*  is correct?
you have a getIsPostHT() in your class? I think this is a common
mistake, and believe it should be *<fb:value* id="isHotTopic"
path="postHT"*/>* since you have either a public boolean isPostHT() or
public boolean getPostHT() in it.

So, it should be :

  *<?xml* version="1.0" encoding="UTF-8"*?>* *
  <fb:context* xmlns:fb="http://apache.org/cocoon/forms/1.0#binding"
path="/"*>* *
    <fb:repeater* id="terms" parent-path="." row-path="terms"*>*
       <fb:identity>
*        <fb:value* id="id" path="termId"*/>* *
      </fb:identity>
*       <fb:on-bind>
*        <fb:value* id="term-name" path="term"*/>* *
        <fb:value* id="isHotTopic" path="postHT"*/>* *
        <fb:value* id="displayName" path="fullDesc"*/>*
       </fb:on-bind>
*    </fb:repeater>* *
    <fb:repeater* id="hotTopics" parent-path="." row-path="hotTopics"*>* *
*       <fb:identity>
*        <fb:value* id="id" path="termId"*/>* *
      </fb:identity>
*       <fb:on-bind>
         *<fb:value* id="displayName" path="fullDesc"*/>* *
*       </fb:on-bind>
*     </fb:repeater>*
  *</fb:context>
*

Let us know if this works any better.

Simone

-- 
Simone Gianni



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message