Re: [Lift] Looking for an example of how to do master detail, on the view side

2009-11-26 Thread Jim Barrows
Excellent.  He's already where I was headed :)

On Wed, Nov 25, 2009 at 8:51 PM, David Pollak feeder.of.the.be...@gmail.com
 wrote:

 Kris blogged about a really nice pattern: http://logji.blogspot.com/

 On Wed, Nov 25, 2009 at 3:16 PM, Jim Barrows jim.barr...@gmail.comwrote:

 I'm using JPA, and need to do a One-Many, or master detail view.  So I
 tried the obvious:
 lift:PersonSnippets.save form=post
 !-- form --
  /lift:PersonSnippets.save
 lift:PersonSnippets.addContactMechanism form=post
 /lift:PersonSnippets.addContactMechanism

 However, the HTML that gets generated is the same form for both.
 Is there an example somewhere I've missed about how to do this?
 --
 James A Barrows

  --
 You received this message because you are subscribed to the Google Groups
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to
 liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.




 --
 Lift, the simply functional web framework http://liftweb.net
 Beginning Scala http://www.apress.com/book/view/1430219890
 Follow me: http://twitter.com/dpp
 Surf the harmonics

  --
 You received this message because you are subscribed to the Google Groups
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to
 liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.




-- 
James A Barrows

--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




Re: [Lift] Looking for an example of how to do master detail, on the view side

2009-11-26 Thread Timothy Perrett
Agreed - Kirs' idea is a nice one. It would be good to incorporate such a 
pattern in the lift examples.

Cheers, Tim

On 26 Nov 2009, at 15:42, Jim Barrows wrote:

 Excellent.  He's already where I was headed :)
 
 On Wed, Nov 25, 2009 at 8:51 PM, David Pollak feeder.of.the.be...@gmail.com 
 wrote:
 Kris blogged about a really nice pattern: http://logji.blogspot.com/
 
 On Wed, Nov 25, 2009 at 3:16 PM, Jim Barrows jim.barr...@gmail.com wrote:
 I'm using JPA, and need to do a One-Many, or master detail view.  So I tried 
 the obvious:
 lift:PersonSnippets.save form=post
 !-- form --
  /lift:PersonSnippets.save
 lift:PersonSnippets.addContactMechanism form=post
 /lift:PersonSnippets.addContactMechanism
 
 However, the HTML that gets generated is the same form for both.  
 Is there an example somewhere I've missed about how to do this?
 -- 
 James A Barrows
 
 
 --
 
 You received this message because you are subscribed to the Google Groups 
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to 
 liftweb+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/liftweb?hl=en.
 
 
 
 -- 
 Lift, the simply functional web framework http://liftweb.net
 Beginning Scala http://www.apress.com/book/view/1430219890
 Follow me: http://twitter.com/dpp
 Surf the harmonics
 
 
 --
 
 You received this message because you are subscribed to the Google Groups 
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to 
 liftweb+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/liftweb?hl=en.
 
 
 
 -- 
 James A Barrows
 
 
 --
 
 You received this message because you are subscribed to the Google Groups 
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to 
 liftweb+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/liftweb?hl=en.

--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




Re: [Lift] Looking for an example of how to do master detail, on the view side

2009-11-25 Thread Derek Chen-Becker
I don't think that that should be happening, but I would need to see the
code for PersonSnippets to really see what's going on.

Derek

On Wed, Nov 25, 2009 at 4:16 PM, Jim Barrows jim.barr...@gmail.com wrote:

 I'm using JPA, and need to do a One-Many, or master detail view.  So I
 tried the obvious:
 lift:PersonSnippets.save form=post
 !-- form --
  /lift:PersonSnippets.save
 lift:PersonSnippets.addContactMechanism form=post
 /lift:PersonSnippets.addContactMechanism

 However, the HTML that gets generated is the same form for both.
 Is there an example somewhere I've missed about how to do this?
 --
 James A Barrows

  --
 You received this message because you are subscribed to the Google Groups
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to
 liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.


--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




Re: [Lift] Looking for an example of how to do master detail, on the view side

2009-11-25 Thread Jim Barrows
package com.nsfw.snippet

import _root_.net.liftweb._
import common.{Empty, Full, Box}
import sitemap.{Loc}
import http._
import js.{JsCmd, JsCmds}
 import JsCmds._
import S._
import SHtml._
import util._
import Helpers._

import _root_.javax.persistence.{EntityExistsException,
PersistenceException}

import com.nsfw.model.Model
import xml.{Group, NodeSeq, Text}
import com.nsfw.bmp.partymodel.party.{PartyContactMechanism, Person}

class PersonSnippets {

  object personVar extends RequestVar(new Person())
  def person = personVar.is

  object partyContactMechanismVar extends RequestVar( new
PartyContactMechanism())
  def partyContactMechanism = partyContactMechanismVar.is

  def addContactMechanism (html: Group) : NodeSeq = {
var comment : String = 
bind(contactMechanism, html,
  comment - Text(partyContactMechanism.getComment()))
  }

  def list(xhtml: NodeSeq): NodeSeq = {

val people =
Model.createNamedQuery[Person](findAllPeople).getResultList()

people.flatMap(person =
bind(person, xhtml,
  firstName - Text(person.getFirstName()),
  middleName - Text(person.getMiddleName()),
  lastName - Text(person.getLastName()),
  edit - SHtml.link(/contact/person/edit.html, () =
personVar(person), Text(?(Edit))),
  delete - SHtml.link(/contact/person/delete.html, () =
personVar(person), Text(?(Delete)))
  ))
  }

  def form = {
lift:PersonSnippets.save form=post
person:id/
person:version/
  div class=span-3
label for=firstName
  lift:locFirst Name/lift:loc
/label
  /div
  div class=span-21 last
  person:firstName/
  /div
  div class=span-3
label for=middleName
  lift:locMiddle Name/lift:loc
/label
  /div
  div class=span-21 last
  person:middleName/
  /div
  div class=span-3
label for=lastName
  lift:locLast Name/lift:loc
/label
  /div
  div class=span-21 last
  person:lastName/
  /div
  div class=span-24
  person:submit/
  /div
/lift:PersonSnippets.save
  }

  def save(xhtml: NodeSeq): NodeSeq = {

bindPerson(xhtml, doSave, Save, false)
  }

  def delete(xhtml: NodeSeq): NodeSeq = {

bindPerson(xhtml, doDelete, Delete, true)

  }

  def doSave() = {

try {
  val name = person.getFirstName() +   + person.getLastName()
  Model.mergeAndFlush(person)
  notice(Saved  + name)
  redirectTo(/contact/list.html)
} catch {
  case ee: EntityExistsException = error(Person already exists)
  case pe: PersistenceException = error(Error adding person);
Log.error(Error adding person, pe)
}

  }

  def doDelete() = {
try {
  var mergedPerson = Model.mergeAndFlush(person);
  val name = mergedPerson.getFirstName() +   +
mergedPerson.getLastName()
  Model.removeAndFlush(mergedPerson);

  notice(Deleted  + name)
  redirectTo(/contact/list.html)
} catch {
  case pe: PersistenceException = error(Error removing person);
Log.error(Error removing person, pe);
}
  }


  def bindPerson(xhtml: NodeSeq, action: () = Unit, submitButtonName:
String, disableAll: boolean): NodeSeq = {
// Hold a val here so that the id closure holds it when we re-enter
this method
val currentId = person.getId()
val currentVersion = person.getVersion()

val disableAttr: Box[String] = if (disableAll) Full(disabled) else
Empty

bind(person, xhtml,
  id - SHtml.hidden(() = person.setId(currentId)),
  version - SHtml.hidden(() = person.setVersion(currentVersion)),
  firstName - (SHtml.text(person.getFirstName(),
person.setFirstName(_)) % (id - firstName) % (readonly -
disableAttr)),
  middleName - (SHtml.text(person.getMiddleName(),
person.setMiddleName(_)) % (id - middleName) % (readonly -
disableAttr)),
  lastName - (SHtml.text(person.getLastName(), person.setLastName(_))
% (id - lastName) % (readonly - disableAttr)),
  submit - SHtml.submit(?(submitButtonName), action))
  }

}

On Wed, Nov 25, 2009 at 4:21 PM, Derek Chen-Becker dchenbec...@gmail.comwrote:

 I don't think that that should be happening, but I would need to see the
 code for PersonSnippets to really see what's going on.

 Derek

 On Wed, Nov 25, 2009 at 4:16 PM, Jim Barrows jim.barr...@gmail.comwrote:

 I'm using JPA, and need to do a One-Many, or master detail view.  So I
 tried the obvious:
 lift:PersonSnippets.save form=post
 !-- form --
  /lift:PersonSnippets.save
 lift:PersonSnippets.addContactMechanism form=post
 /lift:PersonSnippets.addContactMechanism

 However, the HTML that gets generated is the same form for both.
 Is there an example somewhere I've missed about how to do this?
 --
 James A Barrows

  --
 You received this message because you are subscribed to the Google Groups
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, 

Re: [Lift] Looking for an example of how to do master detail, on the view side

2009-11-25 Thread Timothy Perrett
Lift does not use markup like that - there is no magic mapping between 
persistence and view. 

You would most likly have to construct the appropriate master - detail code in 
your snippets and work like that. 

Cheers, Tim

On 25 Nov 2009, at 23:16, Jim Barrows wrote:

 I'm using JPA, and need to do a One-Many, or master detail view.  So I tried 
 the obvious:
 lift:PersonSnippets.save form=post
 !-- form --
  /lift:PersonSnippets.save
 lift:PersonSnippets.addContactMechanism form=post
 /lift:PersonSnippets.addContactMechanism
 
 However, the HTML that gets generated is the same form for both.  
 Is there an example somewhere I've missed about how to do this?
 -- 
 James A Barrows
 
 
 --
 
 You received this message because you are subscribed to the Google Groups 
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to 
 liftweb+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/liftweb?hl=en.

--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




Re: [Lift] Looking for an example of how to do master detail, on the view side

2009-11-25 Thread Jim Barrows
On Wed, Nov 25, 2009 at 4:26 PM, Timothy Perrett timo...@getintheloop.euwrote:

 Lift does not use markup like that - there is no magic mapping between
 persistence and view.

 You would most likly have to construct the appropriate master - detail
 code in your snippets and work like that.



That's what I was trying to do.  There's a list of contact mechanisms
attached to each person.  I was going to use the second form to add the
contact mechanism to the person.




 Cheers, Tim

 On 25 Nov 2009, at 23:16, Jim Barrows wrote:

  I'm using JPA, and need to do a One-Many, or master detail view.  So I
 tried the obvious:
  lift:PersonSnippets.save form=post
  !-- form --
   /lift:PersonSnippets.save
  lift:PersonSnippets.addContactMechanism form=post
  /lift:PersonSnippets.addContactMechanism
 
  However, the HTML that gets generated is the same form for both.
  Is there an example somewhere I've missed about how to do this?
  --
  James A Barrows
 
 
  --
 
  You received this message because you are subscribed to the Google Groups
 Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to
 liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
 .
  For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.

 --

 You received this message because you are subscribed to the Google Groups
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to
 liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.





-- 
James A Barrows

--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




Re: [Lift] Looking for an example of how to do master detail, on the view side

2009-11-25 Thread Derek Chen-Becker
That markup should be in a template file somewhere, which would then call
the snippets appropriately. I don't see markup for a second form, but I
might just be missing it.

A couple of other notes:


   - Generally, on links, omit the suffix and Lift will then do I18N lookup
   for you as needed. That means use /contact/person/edit instead of
   /contact/person/edit.html
   - When you're deleting in JPA, there's no need to do a merge first. Just
   obtain a reference instead and delete that. It's more efficient. Your code
   would look like:

  def doDelete() = {
try {
  Model.removeAndFlush(Model.getReference(classOf[Person],
person.getId());

  notice(Deleted  + person.getFirstName() +   +
person.getLastName())
  redirectTo(/contact/list)
} catch {
  case pe: PersistenceException = error(Error removing person);
Log.error(Error removing person, pe);
}
  }


On Wed, Nov 25, 2009 at 4:26 PM, Timothy Perrett timo...@getintheloop.euwrote:

 Lift does not use markup like that - there is no magic mapping between
 persistence and view.

 You would most likly have to construct the appropriate master - detail
 code in your snippets and work like that.

 Cheers, Tim

 On 25 Nov 2009, at 23:16, Jim Barrows wrote:

  I'm using JPA, and need to do a One-Many, or master detail view.  So I
 tried the obvious:
  lift:PersonSnippets.save form=post
  !-- form --
   /lift:PersonSnippets.save
  lift:PersonSnippets.addContactMechanism form=post
  /lift:PersonSnippets.addContactMechanism
 
  However, the HTML that gets generated is the same form for both.
  Is there an example somewhere I've missed about how to do this?
  --
  James A Barrows
 
 
  --
 
  You received this message because you are subscribed to the Google Groups
 Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to
 liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
 .
  For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.

 --

 You received this message because you are subscribed to the Google Groups
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to
 liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.




--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




Re: [Lift] Looking for an example of how to do master detail, on the view side

2009-11-25 Thread Jim Barrows
ARGGG

It's contactMechanism:comment not contactMechanism.comment

It's colons not dots in xhtml
It's colons not dots in xhtml
It's colons not dots in xhtml
It's colons not dots in xhtml
It's colons not dots in xhtml
it's colons not dots in xhtml
It's colons not dots in xhtml
It's colons not dots in xhtml


On Wed, Nov 25, 2009 at 5:03 PM, Jim Barrows jim.barr...@gmail.com wrote:

 Here's the complete xhtml file:
 lift:surround with=default at=content
 head
 title
 lift:locEdit Person/lift:loc
 /title
 /head
 h1You are editing: /h1

 lift:PersonSnippets.save form=post
 person:id/
 person:version/
 div class=span-8 last

 div class=span-3label for=firstName
 lift:locFirst Name/lift:loc
 /label/div
 div class=span-5
 person:firstName/
 /div
 /div
 div class=span-8 last

 div class=span-3label for=middleName
 lift:locMiddle Name/lift:loc
 /label/div
 div class=span-5
 person:middleName/
 /div
 /div
 div class=span-8 last

 div class=span-3label for=lastName
 lift:locLast Name/lift:loc
 /label/div
 div class=span-5
 person:lastName/
 /div
 /div
 person:submit/
 /lift:PersonSnippets.save

 div class=span-24 last
 h2Contact Mechanisms/h2

 lift:PersonSnippets.addContactMechanism form=post
 label for=comment
 lift:locComment/lift:loc
 /labelcontactMechanism.comment/br/
 input type=radio name=contactMechanism
 value=Email/labelEmail/label
 input type=radio name=contactMechanism value=Postal
 Address/labelPostal Address/label
 input type=radio name=contactMechanism value=Phone
 Number/labelPhone Number/label
 input type=radio name=contactMechanism
 value=Facebook/labelFacebook/label
 input type=radio name=contactMechanism
 value=Twitter/labelTwitter/label
 input type=text name=value/
 button type=submitSave/button
 table summary=A list of all the ways to contact this person
 or organizations title=Contact Mechanisms
 thead
 tr
 thComment/th
 thFrom/th
 thThru/th
 thMechanism/th
 /tr
 /thead
 /table
 /lift:PersonSnippets.addContactMechanism

 /div

 /lift:surround


 On Wed, Nov 25, 2009 at 4:35 PM, Derek Chen-Becker 
 dchenbec...@gmail.comwrote:

 That markup should be in a template file somewhere, which would then call
 the snippets appropriately. I don't see markup for a second form, but I
 might just be missing it.

 A couple of other notes:


- Generally, on links, omit the suffix and Lift will then do I18N
lookup for you as needed. That means use /contact/person/edit instead of
/contact/person/edit.html
- When you're deleting in JPA, there's no need to do a merge first.
Just obtain a reference instead and delete that. It's more efficient. Your
code would look like:

   def doDelete() = {
 try {
   Model.removeAndFlush(Model.getReference(classOf[Person],
 person.getId());

   notice(Deleted  + person.getFirstName() +   +
 person.getLastName())
   redirectTo(/contact/list)

 } catch {
   case pe: PersistenceException = error(Error removing person);
 Log.error(Error removing person, pe);
 }
   }


 On Wed, Nov 25, 2009 at 4:26 PM, Timothy Perrett timo...@getintheloop.eu
  wrote:

 Lift does not use markup like that - there is no magic mapping between
 persistence and view.

 You would most likly have to construct the appropriate master - detail
 code in your snippets and work like that.

 Cheers, Tim

 On 25 Nov 2009, at 23:16, Jim Barrows wrote:

  I'm using JPA, and need to do a One-Many, or master detail view.  So I
 tried the obvious:
  lift:PersonSnippets.save form=post
  !-- form --
   /lift:PersonSnippets.save
  lift:PersonSnippets.addContactMechanism form=post
  /lift:PersonSnippets.addContactMechanism
 
  However, the HTML that gets generated is the same form for both.
  Is there an example somewhere I've missed about how to do this?
  --
  James A Barrows
 
 
  --
 
  You received this message because you are subscribed to the Google
 Groups Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to
 liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
 .
  For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.

 --

 You received this message because you are subscribed to the Google Groups
 Lift group.
 To post to this group, send email to 

Re: [Lift] Looking for an example of how to do master detail, on the view side

2009-11-25 Thread Ross Mellgren
Well, except for after the snippet class name in lift:Snippet tags ;-)

-Ross

On Nov 25, 2009, at 7:45 PM, Jim Barrows wrote:

 ARGGG
 
 It's contactMechanism:comment not contactMechanism.comment
 
 It's colons not dots in xhtml
 It's colons not dots in xhtml
 It's colons not dots in xhtml
 It's colons not dots in xhtml
 It's colons not dots in xhtml
 it's colons not dots in xhtml
 It's colons not dots in xhtml
 It's colons not dots in xhtml
 
 
 On Wed, Nov 25, 2009 at 5:03 PM, Jim Barrows jim.barr...@gmail.com wrote:
 Here's the complete xhtml file:
 lift:surround with=default at=content
 head
 title
 lift:locEdit Person/lift:loc
 /title
 /head
 h1You are editing: /h1
 
 lift:PersonSnippets.save form=post
 person:id/
 person:version/
 div class=span-8 last
 
 div class=span-3label for=firstName
 lift:locFirst Name/lift:loc
 /label/div
 div class=span-5
 person:firstName/
 /div
 /div
 div class=span-8 last
 
 div class=span-3label for=middleName
 lift:locMiddle Name/lift:loc
 /label/div
 div class=span-5
 person:middleName/
 /div
 /div
 div class=span-8 last
 
 div class=span-3label for=lastName
 lift:locLast Name/lift:loc
 /label/div
 div class=span-5
 person:lastName/
 /div
 /div
 person:submit/
 /lift:PersonSnippets.save
 
 div class=span-24 last
 h2Contact Mechanisms/h2
 
 lift:PersonSnippets.addContactMechanism form=post
 label for=comment
 lift:locComment/lift:loc
 /labelcontactMechanism.comment/br/
 input type=radio name=contactMechanism 
 value=Email/labelEmail/label
 input type=radio name=contactMechanism value=Postal 
 Address/labelPostal Address/label
 input type=radio name=contactMechanism value=Phone 
 Number/labelPhone Number/label
 input type=radio name=contactMechanism 
 value=Facebook/labelFacebook/label
 input type=radio name=contactMechanism 
 value=Twitter/labelTwitter/label
 input type=text name=value/
 button type=submitSave/button
 table summary=A list of all the ways to contact this person or 
 organizations title=Contact Mechanisms
 thead
 tr
 thComment/th
 thFrom/th
 thThru/th
 thMechanism/th
 /tr
 /thead
 /table
 /lift:PersonSnippets.addContactMechanism
 
 /div
 
 /lift:surround
 
 
 On Wed, Nov 25, 2009 at 4:35 PM, Derek Chen-Becker dchenbec...@gmail.com 
 wrote:
 That markup should be in a template file somewhere, which would then call the 
 snippets appropriately. I don't see markup for a second form, but I might 
 just be missing it.
 
 A couple of other notes:
 
 Generally, on links, omit the suffix and Lift will then do I18N lookup for 
 you as needed. That means use /contact/person/edit instead of 
 /contact/person/edit.html
 When you're deleting in JPA, there's no need to do a merge first. Just obtain 
 a reference instead and delete that. It's more efficient. Your code would 
 look like:
   def doDelete() = {
 try {
   Model.removeAndFlush(Model.getReference(classOf[Person], 
 person.getId());
 
   notice(Deleted  + person.getFirstName() +   + person.getLastName())
   redirectTo(/contact/list)
 
 } catch {
   case pe: PersistenceException = error(Error removing person); 
 Log.error(Error removing person, pe);
 }
   }
 
 
 On Wed, Nov 25, 2009 at 4:26 PM, Timothy Perrett timo...@getintheloop.eu 
 wrote:
 Lift does not use markup like that - there is no magic mapping between 
 persistence and view.
 
 You would most likly have to construct the appropriate master - detail code 
 in your snippets and work like that.
 
 Cheers, Tim
 
 On 25 Nov 2009, at 23:16, Jim Barrows wrote:
 
  I'm using JPA, and need to do a One-Many, or master detail view.  So I 
  tried the obvious:
  lift:PersonSnippets.save form=post
  !-- form --
   /lift:PersonSnippets.save
  lift:PersonSnippets.addContactMechanism form=post
  /lift:PersonSnippets.addContactMechanism
 
  However, the HTML that gets generated is the same form for both.
  Is there an example somewhere I've missed about how to do this?
  --
  James A Barrows
 
 
  --
 
  You received this message because you are subscribed to the Google Groups 
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to 
  liftweb+unsubscr...@googlegroups.com.
  For more options, visit this group at 
  http://groups.google.com/group/liftweb?hl=en.
 
 --
 
 You 

Re: [Lift] Looking for an example of how to do master detail, on the view side

2009-11-25 Thread David Pollak
Kris blogged about a really nice pattern: http://logji.blogspot.com/

On Wed, Nov 25, 2009 at 3:16 PM, Jim Barrows jim.barr...@gmail.com wrote:

 I'm using JPA, and need to do a One-Many, or master detail view.  So I
 tried the obvious:
 lift:PersonSnippets.save form=post
 !-- form --
  /lift:PersonSnippets.save
 lift:PersonSnippets.addContactMechanism form=post
 /lift:PersonSnippets.addContactMechanism

 However, the HTML that gets generated is the same form for both.
 Is there an example somewhere I've missed about how to do this?
 --
 James A Barrows

  --
 You received this message because you are subscribed to the Google Groups
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to
 liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.




-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.