[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tapestry-user
Subject:    howto change/remove a persistence from AjaxFormLoop
From:       "Sven Homburg" <homburgs () googlemail ! com>
Date:       2008-08-29 13:42:38
Message-ID: 5f29847e0808290642q6ebfbd84vffe27334bfb93f11 () mail ! gmail ! com
[Download RAW message or body]


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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic