Oh! I thought you were just suggesting a method in the earlier email --
I didn't realize that you'd actually done it already. Damn, you're fast.
I'll check out the new code. This looks great. And I like the method --
saving intermediate steps and then purging them later if they're never
completed.
I'm using lots of enumerations already, thanks to this list. :-)
Chas.
Derek Chen-Becker wrote:
> 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 <http://author.name>, author.name
> <http://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]
> <mailto:[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
-~----------~----~----~----~------~----~------~--~---