You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Sven Homburg <ho...@googlemail.com> on 2008/08/29 15:42:38 UTC

howto change/remove a persistence from AjaxFormLoop

hi there,

i have a page to edit an entity.
this entity contains a list of childs connected via OneToMany.
the page contains a component and that component (named ActionsLoop)
contains
an AjaxFormLoop component for edit/add/delete the child entities.

the ActionsLoop component has a parameter:

    @Parameter(required = true, defaultPrefix = BindingConstants.PROP)
    private List<CallOnDutyAction> actionsList;

the actionsList elements wrapped into a map object
(CollectionFactory.newConcurrentMap())
with an unique ID as map key. (AtomicLong ID_ALLOCATOR = new AtomicLong();)

this is my onAddRow event method:

    Object onAddRow()
    {
        CallOnDutyAction action = new CallOnDutyAction();
        action.setMapId(ID_ALLOCATOR.incrementAndGet());
        actionsMap.put(action.getMapId(), action);
        return action;
    }

and this is my onRemoveRow event method:

    void onRemoveRow(CallOnDutyAction item)
    {
        actionsMap.remove(item.getMapId());
    }

and here is my onAfterSubmit

    void onAfterSubmit()
    {
        for (CallOnDutyAction action : actionsMap.values())
        {
            if (action.getId() == 0)
                actionsList.add(action);
        }
    }


if i add a child entity, all is fine: after i submit the form, the new child
added to child list and saved into the database table.

but if i change or remove a child from the AjaxFormLoop nothing is happen
with the modfied childs

where is my fault ?

-- 
with regards
Sven Homburg
http://www.chenillekit.org
http://tapestry5-components.googlecode.com