It would work the same way, since it grabs its stuff up-front. Behind the
scenes, you use a LDM as the actual model.
On Mon, Dec 8, 2008 at 1:56 PM, Daan van Etten <[EMAIL PROTECTED]> wrote:
> Hi James,
>
> How does this work with a Hibernate-managed object? Did you test it with
> Hibernate?
>
> Op 8 dec 2008, om 19:45 heeft James Carman het volgende geschreven:
>
>
> Sorry for the delay. A shadow model basically grabs the actual model's
>> value in the beginning and caches it. You actually edit the shadowed
>> model.
>> Then, when you're done with all of your edits you call "commit" on all of
>> your shadow models to write back into the originals. So, I don't think
>> you'll get a LazyInitializationException. I guess it depends on what
>> you're
>> shadowing. I've got an implementation I call ProxyModelManager in
>> Wicketopia and I hope to rename it to ShadowModelManager. I like shadow
>> much better.
>>
>> On Mon, Dec 8, 2008 at 8:29 AM, Benjamin Ernst <[EMAIL PROTECTED]
>> >wrote:
>>
>> Hi James,
>>>
>>> thanks for your help.
>>>
>>> I think "shadow" models could work, when I only access non-lazy fields.
>>> Otherwise I would get a LazyInitializationException.
>>>
>>> Or what do you exactly mean by "shadow" models?
>>>
>>> - Benjamin
>>>
>>> On Mon, Dec 8, 2008 at 1:32 PM, James Carman <[EMAIL PROTECTED]
>>>
>>>> wrote:
>>>>
>>>
>>> Would "shadow" models help?
>>>>
>>>> On Mon, Dec 8, 2008 at 7:06 AM, Benjamin Ernst <
>>>> [EMAIL PROTECTED]
>>>>
>>>>> wrote:
>>>>>
>>>>
>>>> Hi everybody,
>>>>>
>>>>> I have a little Problem with LDMs:
>>>>>
>>>>> I have a page with a ListView and for each item in the ListView the
>>>>>
>>>> user
>>>
>>>> can
>>>>> open a modalWindow to edit the item.
>>>>>
>>>>> My Problem is, that I don't want to persist the item to the DB from the
>>>>> modalWindow. Only after the User confirms the changes in the page with
>>>>>
>>>> the
>>>>
>>>>> ListView, all these changes for all items from the ListView should be
>>>>> persisted. Or the User presses "abort" and nothing is persisted.
>>>>>
>>>>> When I use LDMs changes that are made in the modalWindow are never
>>>>>
>>>> shown
>>>
>>>> in
>>>>
>>>>> the ListView, because the models are detached.
>>>>>
>>>>> I could use normal Models or the actual Objects for this, but then I
>>>>>
>>>> might
>>>>
>>>>> run into lazy-initialization-problems.
>>>>>
>>>>> Has anybody a solution for this problem, or is this simply not possible
>>>>>
>>>> in
>>>>
>>>>> this way?
>>>>>
>>>>> Thanks in advance,
>>>>>
>>>>> Benjamin
>>>>>
>>>>> -------------------------------------------------------------------
>>>>>
>>>>> My Code looks like this:
>>>>>
>>>>> ListView<Account> accountListView = new
>>>>>
>>>> ListView<Account>("accountList",
>>>
>>>> accountList)
>>>>> {
>>>>> @Override
>>>>> protected void populateItem(ListItem<Account> item) {
>>>>> DetachableEntityModel<Account> account = new
>>>>> DetachableEntityModel<Account>(item.getModelObject());
>>>>>
>>>>> item.add(new Label("accountName", new
>>>>> PropertyModel<String>(account, "name")));
>>>>> item.add(new Label("accountNumber", new
>>>>> PropertyModel<String>(account, "number")));
>>>>>
>>>>> item.add(new AjaxLink<Account>("edit", account)
>>>>> {
>>>>> @Override
>>>>> public void onClick(AjaxRequestTarget target) {
>>>>> modalWindow.showPage(target, new
>>>>> AccountEditPage(modalWindow, this.getModel()));
>>>>> }
>>>>> });
>>>>> }
>>>>> };
>>>>> cont.add(accountListView);
>>>>>
>>>>> AjaxLink save = new AjaxLink("saveAccounts")
>>>>> {
>>>>> @Override
>>>>> public void onClick(AjaxRequestTarget target) {
>>>>> User user = userModel.getObject();
>>>>> user.getAccounts().clear();
>>>>> user.getAccounts().addAll(accountList);
>>>>>
>>>>>
>>>>> ServiceLocator.instance().getUserService().saveUser(user);
>>>
>>>> }
>>>>> };
>>>>>
>>>>>
>>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>