Well, I've already checked in the code for keeping the object in the
continuation instead of the ID on the wip-dc-jpa-jta branch of liftweb. I
thought we had discussed this in a previous email. To get the object instead
of the Id you just grab a val on the object and re-inject it with a hidden
element:
object authorVar extends RequestVar(new Author())
def author = authorVar.is
...
// Hold a val here so that the "id" closure re-injects it when we
re-enter this method
val heldAuthor = author
bind("author", xhtml,
"id" -> SHtml.hidden({authorVar(Model.merge(heldAuthor))}),
"name" -> SHtml.text(author.name, author.name = _),
"submit" -> SHtml.submit(?("Save"), doAdd))
Notice that I reinject it by passing the object through the Model.merge
method so that it becomes attached to the new session on the next request
cycle. As for state, I would probably use an enumeration to represent that.
The object would be persisted to the DB each time, but combined with a
record timestamp and a lifecycle interceptor to set it each time, you could
do periodic purges of "transient" objects. For instance, you'd add the
following field and method to your entities to get the timestamp:
@Temporal{val value = TemporalType.TIMESTAMP}
var recordTime : java.util.Date = _
@PrePersist
def updateTimestamp = recordTime = new java.util.Date
Enumerations have been discussed in a previous thread, but let me know if
you run into problems or have more questions.
Derek
On Fri, Oct 17, 2008 at 5:08 PM, Charles F. Munat <[EMAIL PROTECTED]> wrote:
>
> Derek,
>
> Have you figured out how to keep the object in the continuation instead
> of just the id?
>
> Also, I'm working on a form. I'd like it to have four "states":
>
> 1. Initial form is blank
> a. Click Save to save the data
> b. Click Preview to preview the data
>
> 2. Preview shows what it will look like
> a. Click Save to save the data
> b. Click Edit to edit the data
>
> 3. Edit shows the form with the previously entered values
> (Same as add form, but preloaded)
> a. Click Save to save the data
> b. Click Preview to preview the data
>
> 4. Response shows the saved data
>
> Any ideas on how to do this? Anyone else?
>
> Chas.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---