On Jul 18, 2006, at 3:14 AM, Simone Gianni wrote:

The insert bean requires a class and method, the method is referred to
the context bean, so you need an addXXX method on you bean.

OK, I get it... after looking at the source code I see how this works.

This was counterintuitive to me after just recently learning the <multi-value> binding. I expected the repeater binding to work in the same way when it comes to actually adding to the List (viz: letting JXPath do it).

So, the repeater binding calls a method (given by @addmethod) on the context bean, i.e. the owner of the collection, to create and add a new item... this is the most flexible way to do it, and in any case I understand the need (for beans) to at least delegate creation of the model object to something that knows how to create it :-). I just expected something like a factory, instead of of a method that actually does the insertion into the collection. What the multi-value binding does is to just go ahead and create the context for the new item, and JXPath expands the collection (which must be an Array or a List) by adding a null item.

But all this will not solve your problem, this is because there is no
way to tell to the repeater binding that the context bean and a field
are the same (the fb:value with path="." that never works).

It works for loading :-)...

Anyway... I think the "context bean" and the "field" are really not the same! The path for the field isn't relative to the binding context path, it's relative to the repeating item, which would be something like "/parent/things[3]". So my field path is really like "/parent/things[3]/." (instead of the typical "/parent/things/[3]/beanProperty), and since in fact is a String, JXPath should be able to set it just fine.

I added an addWhatever() method to my model, and now the new items (Strings) are added when I save the form... unfortunately they are empty Strings (i.e., as created by my addWhatever() method). Not sure why it isn't working... I guess if I don't figure it out soon here, I'll just punt and introduce a new class w/ a bean getter/setter, and do it the bean way.

—ml—


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to