Hi Sylvain, thx for your reply...
....However...I realized that I have a nomenclature clash with my choice of the name "model". I've been using the v2 API for a long time, so I forgot in v1, there is a Form.model property that denotesthe widget value tree.The "model" property is only available on the toplevel form JS object, so there may not be a clash.It's not a hard "name clash", but it is a nomenclature clash in that it's a different sense of the term "model". My new row "model" property is truly the "model", as in "MVC" or as in "loadFormFromModel()". The v1 "model" is "model" in terms of "formmodel", I guess. I just think it's too confusing to have both senses. I actually sort of wish the v1 "model" were called something else, because it isn't the model /a la/ MVC.You're right. The "form.model" is actually the value tree.
Maybe form.model should be renamed to "form.value"! Then you would have these two expressions that mean the same thing (just as they look like they should! :-):
form.value.foobar
and
form.lookupWidget('foobar').value
, right? :-)
But for now in my working version of the code I settled on "rowModel"
to expose the row model object in Flowscript and JXT.
Now then, the following exchange has me totally confused:
It doesn't seem good to me to provide at the API level a way to link the form to the data model,No, no, it /is/ good... :-) [ ...my rambling snipped...]However, there are some uses cases where this makes sense. You canthen use widget attributes (see get/setAttribute) to attach some application data of your liking to any widget, including repeater rows.See, that's the problem, this is what I have to deal with currently :-)... I have two parallel structures: a Collection, and a Repeater. If the Repeater does not give me a "view" to its collection, then I have to do some kind of iteration to create associations somewhere between the repeater rows and the collection elements, and this just feels silly and wasteful. I've done it this way, decorating the repeater rows with handles to the model data, and I just think that since the binding layer is already iterating across the collection, it should do this decoration for me! :-).Yes. That's the idea behind the "bound repeater binding" idea Reinhard pointed to.
Right. Which was your idea, and which I think I have gone and implemented before I knew that somebody else had thought of it :-)... Or have I not? Maybe I am misunderstanding Reinhard's reference and it isn't really the same thing... or maybe you are misunderstanding me, and thinking it's not the same thing, but it really _is_? :-)
Are you saying, "Ah yes, you're right... I thought of this before, and now I remember why it _is_ a good idea (+1! :-)" ?
Or — are you saying "Ah, it looks like I did think of this too once, but now on second thought I'm not so sure it was a good idea" ?
I could live with there being a "callback" facility in the repeater binding language, e.g. <fb:javascript> within <fb:on-bind>... know what I mean? But that's sort of beyond my ability to implement, and I was looking for something that I could actually do :-)Extending the repeater binding to keep the connection to the data model may be easier, no?
Well, it certainly was awfully easy :-) Tell you what, the change is so ridiculously small, I'll just attach the diffs (they are against src/blocks/forms/java/org/apache/cocoon/forms) and you can see if we're talking about the same thing. At first this amounted to about 6 lines of code added, before I added the convenience flowscript function (that I had mentioned in the original post that I wanted to add... this doubled :-) the size of the mod). BTW, this function — 'getRowModel()' — I only added it in v2 ('cuz that's what I'm using! :-). When I looked at v1's ScriptableWidget, I hesitated when I saw that there are so few javascript functions defined there, and I wasn't sure if this is really the right idiom for v1... Care to comment?
Cheers, —ml—
rowModel.diff
Description: Binary data
