Francois Armand wrote:
Hello T5 user,
I would like to use the AjaxFormLoop component to edit list of simple
values, or more precisely a least of object whitout an "id" property.
I thought I could use their position in the list as identifier, but
I'm stuck with the definition of the PrimaryKeyEncoder : how can I
code the "toKey(Bean value)" method ? There is no "index" in
AjaxFormLoop, and I think I will have to differentiate between render
phase and action one, what seems a little complex.
In the AjaxFormLoop example, it is trivial, because the bean knows
it's id. But in my case, I don't see what to relies on. hashcode and
the like are not possible, because it's completely valid to have two
equals object in the list.
So... I'm surely missing something obvious, but I don't see what.
Could somebody show me the way ? Any help welcome :)
For the posterity : in fact, it's quite simple : just use two lists. The
real one, that keep your beans. A list of string (or other identifier).
Use this second list for the ajaxformloop t:source and t:value parameter.
When you add a row, create a new id, add this id in the id list, and add
a new bean at the same index into the bean list.
When you remove a row, find the index of the id to be deleted and also
remove the bean with this index.
So, the two lists must stay in sync, but has T5 components are thread
safe, it should be ok ;)
I knew I was missing something simple.
--
Francois Armand
Etudes & Développements J2EE
Groupe Linagora - http://www.linagora.com
Tél.: +33 (0)1 58 18 68 28
-----------
http://fanf42.blogspot.com
InterLDAP - http://interldap.org
FederID - http://www.federid.org/
Open Source identities management and federation
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org