Hi,
I'm looking for suggestions on how to improve this EditPerson page to
T5 best practice.
private Long _personId;
@Persist
private Person _person;
public void onActivate(Long id) { _personId = id; }
public Long onPassivate() { return _personId; }
void onPrepareFromForm() {
if (_person == null || _person.getId().equals(_personId)) {
_person =
getSecurityFinderService().findPerson(_personId);
}
}
Object onSuccess() {
if (...a bit of validation logic detects an error...) {
_form.recordError(...);
return null;
}
etc...
_person = null;
return _nextPage;
}
Object onActionFromCancel() {
_person = null;
return _previousPage;
}
void cleanupRender() {
_form.clearErrors();
}
Some notes and questions:
1. Persist - Is there an alternative? It's used here to keep _person
populated in case onSuccess() detects an error and redisplays the page.
2. Housekeeping - I'm nullifying _person in each method that returns a
different page. This seems clumsy. Suggestions?
3. Thread-safety - is there a thread-safety issue if the user has
opened a new window in same browser - can T5 tell them apart or do
they share the same HttpSession?
4. onPrepareFromForm() - this looks a bit clumsy to me. If the user
hits Reload, or if the user hits the Back button then "pagelinks" back
in, onPrepareFromForm() wlll not call findPerson(...). The _person
isn't refreshed at all! Thoughts?
Thanks,
Geoff