Quick update on this:

If you're persisting the ID of an entity so you don't have to embed it
in the page (the main conclusion from this thread), the pseudocode I
used before with regard to the pageBeginRender implementation has two
potential gotchas in it (found so far).

To refresh, I said: "Have your page implement the
PageBeginRenderListener, and in your pageBeginRender method, if the ID
is not null, "get" the object (I'm using Hibernate semantics) if you're
not rewinding, and "load" the object if you are."


First, if you're using Hibernate semantics, you'll probably want to
"get" the entity either way, or you'll likely get a
LazyInitializationException depending on what you've OGNL-mapped.


Second, if you're using validation, you need to be careful not to
re-query the object out when rendering after a validation error.
Consider the order:

1.  Submit the form
2.  pageBeginRender(rewind) - queries out object
3.  rewind - sets mapped-form-properties to object
4.  validation - finds error
5.  listener - since there were validation errors, returns "this"
6.  pageBeginRender(render) - queries out object
7.  renders with persisted properties, not the invalid inputs <--
problem


New pseudo-pseudocode for pageBeginRender:
...
if (getValidationDelegate().getHasErrors()) {
  if (id != null) {
    setEntity(getEntityService().get(id));
  } else {
    setEntity(new Entity());
  }
}
...

i.e. If there were errors, you'll want to render the page with the data
that was entered.


Jim

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to