[Lift] Re: Preview form (JPA)
Chas, this like that takes quite some forethought before implementing. (holding on to entity in either transient, detached or persistent state. And then you have the problem that if you try to save the transient entity, and it fails, it still gets allocated an identifier, and then you have a transient entity with an identifier) The simplest way around this is to save the object but have different statuses (DRAFT,LIVE) etc. There are surely other ways of doing it aswell, this is just from the top of my head. Cheers, Viktor On Sat, Oct 18, 2008 at 1:08 AM, 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. -- Viktor Klang Senior Systems Analyst --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com 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 -~--~~~~--~~--~--~---
[Lift] Re: Preview form (JPA)
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 liftweb@googlegroups.com 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 -~--~~~~--~~--~--~---
[Lift] Re: Passing functions as arguments
Hey Marius, Ok, so i've been putting this together, and have the following: case class PaypalEventAction(status: PaypalTransactionStatus, functions: List[() = PaypalActionHandler]) So, when I then create a subclass for PaypalActionHandler which I create a new instance of like: case class SecondPendingHandler extends PaypalActionHandler { println(FFDGDFGDF) } PaypalEventAction(PendingPayment, List( SecondPendingHandler() )) Then I get this error: found : this.SecondPendingHandler required: () = this.PaypalActionHandler PaypalEventAction(PendingPayment, List( SecondPendingHandler() ) ) What i want to do is have my PaypalIPN class have a list of PaypalEventAction and then operate on that internal list so that I can filter the list depending on the resultant action from paypal. Any pointers on why this is bombing would be a great help Cheers Tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com 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 -~--~~~~--~~--~--~---
[Lift] Re: Preview form (JPA)
I have a subscription to O'Reilly's Safari bookshelf. I'll look for it there. I've been reading Manning's EJB3 in Action and O'Reilly's Harnessing Hibernate online. It's a pain reading online, but I'm already shelling out almost $50/month for the service... Thanks for the recommendation. Understanding Hibernate in Java isn't difficult. My struggle (as always) is thinking in Scala. Chas. Tim Perrett wrote: Hey Chas, Can I suggest this book: http://www.amazon.com/Hibernate-Made-Easy-Persistence-Annotations/dp/0615201954 It sounds to me that you need to understand the magic of the entity manager and how that can be utilized. I read this book a little while ago and must say it was an eye opener. Dont be put off my the crap looking cover and informal writing style, there is some great information in there. Cheers Tim On Oct 18, 12:08 am, 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 liftweb@googlegroups.com 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 -~--~~~~--~~--~--~---
[Lift] Re: Preview form (JPA)
I like this idea a lot. And it seems Derek does, too. This will also work well as practice for a multi-page survey form I have to build later this month. Thanks. Chas. Viktor Klang wrote: Chas, this like that takes quite some forethought before implementing. (holding on to entity in either transient, detached or persistent state. And then you have the problem that if you try to save the transient entity, and it fails, it still gets allocated an identifier, and then you have a transient entity with an identifier) The simplest way around this is to save the object but have different statuses (DRAFT,LIVE) etc. There are surely other ways of doing it aswell, this is just from the top of my head. Cheers, Viktor On Sat, Oct 18, 2008 at 1:08 AM, 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. -- Viktor Klang Senior Systems Analyst --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com 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 -~--~~~~--~~--~--~---
[Lift] Re: Passing functions as arguments
lol - sorry that was lame answering my own question but I just figured it out. If I go with something like: https://gist.github.com/9df3baee3793b750e42e then it can be truley arbitrary code; comparatively a subclass could never the as flexible. Pretty neat. Now my IPN code will operate a little like this: val pending = PaypalEventAction(PendingPayment, List( () = println(hello) // update your database or do whatever here )) val refunded = PaypalEventAction(RefundedPayment, List( () = println(hello) // update your database or do whatever here )) PaypalIPN().onEvent(pending).onEvent(refunded) What are people's thoughts? Cheers Tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com 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 -~--~~~~--~~--~--~---
[Lift] Re: Stand alone download
Its never really an issue for us as were all connected to the net. Can I ask why you cant connect that machine to the net? A fair number of secure organizations (corporate, government, etc.) may opt to not have direct Internet connections. It's not that uncommon. Yes, it's true. Your best bet is to build lift, then copy all the sources in .m2 over to your disconnected box - im not sure your going to find this an easy way to work im afraid. I'll work on putting together a zip'ed .m2 based on a virgin Lift install. Thank you very much! :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com 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 -~--~~~~--~~--~--~---
[Lift] Re: Passing functions as arguments
Just been nooding this somemore, and one thing I cant seem to figure is why / how this is better than supplying a list of custom subclasses that implement a supplied abstract class? Just been having a play with some ideas, and how does your suggestion improve upon something like this: https://gist.github.com/9df3baee3793b750e42e It goes without saying that this is *just an example* and the execute method of my abstract class would do something significantly more usefull! lol. Cheers Tim On Oct 18, 4:30 pm, Tim Perrett [EMAIL PROTECTED] wrote: Hey Marius, Ok, so i've been putting this together, and have the following: case class PaypalEventAction(status: PaypalTransactionStatus, functions: List[() = PaypalActionHandler]) So, when I then create a subclass for PaypalActionHandler which I create a new instance of like: case class SecondPendingHandler extends PaypalActionHandler { println(FFDGDFGDF) } PaypalEventAction(PendingPayment, List( SecondPendingHandler() )) Then I get this error: found : this.SecondPendingHandler required: () = this.PaypalActionHandler PaypalEventAction(PendingPayment, List( SecondPendingHandler() ) ) What i want to do is have my PaypalIPN class have a list of PaypalEventAction and then operate on that internal list so that I can filter the list depending on the resultant action from paypal. Any pointers on why this is bombing would be a great help Cheers Tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com 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 -~--~~~~--~~--~--~---