On 28/10/2011 12:49 PM, Igor Vaynberg wrote:
i think you are blowing this way out of proportion.
I hope so :)
this only affects components that (A) modify their own model but do
not update it and *also* (B) have their model loaded for some reason
before they update it.
This is not the type of situation I meant. What you describe is a clear
situation where the component doing the update can easily handle
detaching its model for a refresh.
With a business layer and DTOs, doing the update correctly on the wicket
model directly is impossible without replicating the business logic in
the web client. That's why I say that the model can be detached and
refreshed above and not just updated.
We could also argue that event handlers accessing model objects (see my
issue 1) should systematically detach all accessed models after their
processing to avoid stale models.
However, Issue 2 still remains. Here is a more detailed example to
illustrate it:
class PersonDto {
private int id;
// other fields and methods
}
class ShowPersonPanel extends Panel {
private int personId;
// other fields
MyPanel (IModel<PersonDto> model) {
personId = model.getObject().getId(); // triggers load of LDM
// Pass model to other components + other stuff
}
}
class UpdatePersonPanel extends Panel {
// adds a component of type StatelessAjaxUpdatePersonLink
}
class StatelessAjaxUpdatePersonLink extends Link {
private IModel<PersonDto> personModel;
onClick(AjaxRequestTarget target) {
updateSomePersonAttribute(personModel);
personModel.detach();
target.add(this);
}
}
Consider a stateless page with a ShowPersonPanel and an
UpdatePersonPanel. Further, when the StatelessAjaxUpdatePersonLink is
clicked, the ShowPersonPanel is added to the request target by other code.
Sequence of events for stateless ajax request:
1-New page instance created with ShowPersonPanel and UpdatePersonPanel,
not sharing the same IModel<PersonDto> instance for some reason. Note
that the constructor of ShowPersonPanel triggers the load of its
PersonDto LDM.
2-Ajax link listener is invoked which updates the persistent Person and
detaches the now stale model
3-ShowPersonPanel is added to the ajax target (through events perhaps)
4-ShowPersonPanel and UpdatePersonPanel are rendered. ShowPersonPanel
has stale LDM and UpdatePersonPanel has fresh LDM.
I don't see how to manage this without either A) a blanket detach() of
all models or B) some complicated panel and model inter-dependency
management.
Note that this sequence of events is not the same for stateful pages.
The stateful pages do not construct a new page instance before invoking
the link listener so no outside LDMs are loaded.
Regards,
Bertrand
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org