[Lift] Re: Alternate part of view

2009-08-05 Thread Naftoli Gugenheim

It doesn't, because it has to replace its contents bound, and the other view 
part has to be replaced with nothing, so it's less concise than FuncBindParams.

-
marius d. wrote:


Please see chooseTemplate from Helpers._ (It's actually defined in
BindHelpers)

For examples see:

\sites\example\src\main\webapp\guess.html
\sites\example\src\main\scala\net\liftweb\example\snippet
\CountGame.scala

.. see if that helps you case.

Br's,
Marius

On Aug 6, 6:44 am, Naftoli Gugenheim  wrote:
> What's the smartest / most concise way to achieve the following in the 
> corresponding view xhtml and snippet code:
> Parts of the view have to change, depending on whether something is set. For 
> example, in the area where you select the client, if the client is None, then 
> it displays an interface to select a client. If it's set to a Some then it 
> displays the client's details with a button to unset it. This pattern is 
> repeated.
> My current strategy is to have two elements, req:noClient and req:client, 
> which have different xhtml contents. Then in the snippet I bind them to two 
> NodeSeq functions, one that binds useful contents when the client is None and 
> returns NodeSeq.Empty otherwise; and another function that binds when it's a 
> Some and returns Empty otherwise. However, it seems to be somewhat redundant 
> in theory.
> So does anyone have a better way of switching view parts?
> Thanks.


--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Alternate part of view

2009-08-05 Thread marius d.

Please see chooseTemplate from Helpers._ (It's actually defined in
BindHelpers)

For examples see:

\sites\example\src\main\webapp\guess.html
\sites\example\src\main\scala\net\liftweb\example\snippet
\CountGame.scala

.. see if that helps you case.

Br's,
Marius

On Aug 6, 6:44 am, Naftoli Gugenheim  wrote:
> What's the smartest / most concise way to achieve the following in the 
> corresponding view xhtml and snippet code:
> Parts of the view have to change, depending on whether something is set. For 
> example, in the area where you select the client, if the client is None, then 
> it displays an interface to select a client. If it's set to a Some then it 
> displays the client's details with a button to unset it. This pattern is 
> repeated.
> My current strategy is to have two elements, req:noClient and req:client, 
> which have different xhtml contents. Then in the snippet I bind them to two 
> NodeSeq functions, one that binds useful contents when the client is None and 
> returns NodeSeq.Empty otherwise; and another function that binds when it's a 
> Some and returns Empty otherwise. However, it seems to be somewhat redundant 
> in theory.
> So does anyone have a better way of switching view parts?
> Thanks.
--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Exception for S.? while booting

2009-08-05 Thread marius d.

No really. That is for constructing an S object, as it needs the
reuest and session object. Lift calls that when processing statefull
requests and rendering pieline, bound functions etc. are executed in
this context. There is another function S.initIfUninitted where S can
be initialized having only the session and no request. This is used by
Lift inside Comet actors.

Typically applications should not care about this.

Br's,
Marius

On Aug 6, 12:50 am, Naftoli Gugenheim  wrote:
> I just read the scaladoc comment of S.init. Does it have anything to do with 
> this subject?
>
> -
>
> Heiko Seeberger wrote:
>
> Ah, yes!Sorry, I did not get the point, but obviously the val is to be
> blamed ;-)
> Now it's running, thanx!!!
>
> Heiko
>
> 2009/8/5 marius d. 
>
>
>
> > I'm aware about the override thing but I don't see why you would do it
> > in such way. Since you don't have state, you don't have a session =>
> > you don't have S. Are you using a statelesDispatchPf ?
>
> > You can do:
>
> > 1. Use your own ResourceBundles
> > 2. Or a hacky thingy like:
>
> > val session = LiftRules.getLiftSession(request, httpRequest)
> > S.initIfUninitted(session) {
> >   // Now you should be able to call call S.?(...)
> > }
>
> > Localization is "bound" to state as ResourceBundles
>
> > You exception thrown in Boot probably was cause because you used a val
> > and it obviously tried to initialize it. Using a def or lazy val it
> > would be evaluated properly upon requests.
>
> > Typically S.? is used in the context of page rendering, Ajax functions
> > processing, DispatchPF. All these are executed in a stateful context
> > where S is available. To process pure stateless requests you have
> > LiftRules.statelessDispatchTable, and a few request processing
> > hooks ... but do you really need those?
>
> > Do you have a usecase when you want to process a pure stateless
> > requests and need Lift's localization?
>
> > Br's,
> > Marius
>
> > On Aug 5, 8:50 am, Heiko Seeberger 
> > wrote:
> > > def can be overridden with val. But this is a Scala thingy, please do not
> > > bother. If it makes you easier replace val with def.
> > > The question remains: How can i18n be done in "stateless" (request state)
> > > cases?
>
> > > 2009/8/5 marius d. 
>
> > > > I thought validations is a function not a val:
>
> > > > override val validations should probably be
>
> > > > override def validations ?
>
> > > > or
>
> > > > override lazy val validations ?
>
> > > > Br's,
> > > > Marius
>
> > > > On Aug 5, 7:48 am, Heiko Seeberger 
> > > > wrote:
> > > > > I would like to internationalize my code. Something like:
> > > > > Mapper class:
>
> > > > > class Course
> > > > >   extends LongKeyedMapper[Course]
> > > > >   with IdPK {
>
> > > > >   ...
>
> > > > >     override val validations =
> > > > >       valMinLen(3, ?("minLen", 3)) _ ::
> > > > >       valMaxLen(50, ?("maxLen", 50)) _ ::
> > > > >       Nil
> > > > >   }
>
> > > > > Localized messages:
>
> > > > > minLen=At least %s characters required!
> > > > > maxLen=At most %s characters allowed!
>
> > > > > Thanx
> > > > > Heiko
>
> > > > > 2009/8/4 marius d. 
>
> > > > > > S lifetime is per request. S is not constructed on Boot. Could you
> > > > > > post a code snippet on what you're trying to achieve?
>
> > > > > > Br's,
> > > > > > Marius
>
> > > > > > On Aug 4, 12:43 pm, Heiko Seeberger <
> > heiko.seeber...@googlemail.com>
> > > > > > wrote:
> > > > > > > Hi,
>
> > > > > > > When I try to use internationalization via S.? in a Mapper class,
> > I
> > > > get
> > > > > > the
> > > > > > > below exception while booting Lift. It seems that S._resBundle is
> > > > null
> > > > > > when
> > > > > > > Schemifier tries to do its work.
>
> > > > > > > Is this a bug or a feature (S must not be used outside the
> > request
> > > > life
> > > > > > > cycle). If last, how to i18n then?
>
> > > > > > > Thanx
> > > > > > > Heiko
>
> > > > > > > 0 [main] ERROR lift - Failed to Boot
> > > > > > > java.lang.ExceptionInInitializerError
> > > > > > > at bootstrap.liftweb.Boot.boot(Boot.scala:38)
> > > > > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > > > > > > at
>
> > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> > > > > > > at
>
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> > > > > > > at java.lang.reflect.Method.invoke(Method.java:585)
> > > > > > > at
>
> > net.liftweb.util.ClassHelpers$$anonfun$createInvoker$1.apply(ClassHelpers.scala:408)
> > > > > > > at
>
> > net.liftweb.util.ClassHelpers$$anonfun$createInvoker$1.apply(ClassHelpers.scala:406)
> > > > > > > at
>
> > net.liftweb.http.DefaultBootstrap$$anonfun$boot$1.apply(LiftRules.scala:1096)
> > > > > > > at
>
> > net.liftweb.http.DefaultBootstrap$$anonfun$boot$1.apply(LiftRules.scala:1096)
> > > > > > > at net.liftweb.util.Full.map(Box.scala:330)
> > > > > > > at net.liftweb.http.DefaultBootstrap$.boot(Lift

[Lift] Alternate part of view

2009-08-05 Thread Naftoli Gugenheim

What's the smartest / most concise way to achieve the following in the 
corresponding view xhtml and snippet code:
Parts of the view have to change, depending on whether something is set. For 
example, in the area where you select the client, if the client is None, then 
it displays an interface to select a client. If it's set to a Some then it 
displays the client's details with a button to unset it. This pattern is 
repeated.
My current strategy is to have two elements, req:noClient and req:client, which 
have different xhtml contents. Then in the snippet I bind them to two NodeSeq 
functions, one that binds useful contents when the client is None and returns 
NodeSeq.Empty otherwise; and another function that binds when it's a Some and 
returns Empty otherwise. However, it seems to be somewhat redundant in theory.
So does anyone have a better way of switching view parts?
Thanks.



--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Where do I place a default.props file for use by Boot?

2009-08-05 Thread Jeff McKenna

Thanks for the suggestion.  It seems to have worked.
jeff
On Aug 5, 5:31 pm, Tim Nelson  wrote:
> Try src/main/resources/props
>
> On Wed, Aug 5, 2009 at 7:19 PM, Jeff McKenna  wrote:
>
> > Newbee:
> > I have a default.props file that I was able to read once.  I seem to
> > have lost the incantation.
> > Where do I put it.  I thought src/resouces would work.  But boot can
> > not see to read the file.
> > Any suggestions?
--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: New features

2009-08-05 Thread Naftoli Gugenheim

Building causes a stack overflow?
So the question is, is it the resident compiler or plain scalac also crashes? 
Or just the presentation compiler? What do you see in the error log view or 
file?
I get compiler crashes very often when doing fancy mapper type related tricks.

-
glenn wrote:


Naftoli,

Hate to do this to you, but I'm getting the following error using
ManyToMany for Users to Roles:

Message: java.lang.RuntimeException: Broken join
scala.Predef$.error(Predef.scala:76)
net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$
$anonfun$apply$1.apply(ManyToMany.scala:54)
net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$
$anonfun$apply$1.apply(ManyToMany.scala:54)
net.liftweb.util.EmptyBox.openOr(Box.scala:372)
net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children
$1.apply(ManyToMany.scala:54)
net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children
$1.apply(ManyToMany.scala:54)
scala.List.map(List.scala:812)
net.liftweb.mapper.ManyToMany$MappedManyToMany.children
(ManyToMany.scala:54)
net.liftweb.mapper.ManyToMany$MappedManyToMany.elements
(ManyToMany.scala:96)
scala.Seq$class.flatMap(Seq.scala:293)
net.liftweb.mapper.ManyToMany$MappedManyToMany.flatMap
(ManyToMany.scala:44)

 def edit(ns: NodeSeq): NodeSeq = {
val theUser = view.entity
val addRole = TheBindParam("insert", view.snippet.link("edit", ()
=> theUser.roles += new Role, Text(S?("Add Role"

bind("user", ns,
 "firstname" -> text(theUser.firstName.is, theUser.firstName
(_), ("size","20")),
 "lastname" -> text(theUser.lastName.is,theUser.lastName(_),
("size", "30")),
 "roles" -> theUser.roles.flatMap{role =>
  bind("role", ns,
  "name" -> role.name.toForm,
  "remove" -> SHtml.submit(S?("Remove"), ()=>
theUser.roles -= role)
  )
  },
 addRole,
 "submit" -> SHtml.submit(S?("Save"), ()=>view.save)
 )
}

The offending code seems to be the line: "roles" ->
theUser.roles.flatMap{
in the above bind method when I click on the addRole link.

Here's my User class:

class User extends MegaProtoUser[User] with ManyToMany[Long,User]{
  def getSingleton = User // what's the "meta" server

   object roles
extends MappedManyToMany(UserRole, UserRole.user, UserRole.role,
Role)

}

What am I doing wrong? You can see how difficult it is to slog through
this code, let alone just
trying to explain the problem so I can get help.

On Aug 5, 9:57 am, Naftoli Gugenheim  wrote:
> I'll try.
> By the way, as per my correction, you can implement list the regular way 
> without ModelView, and just use ModelSnippet's load function in your edit 
> link or button, passing it the User instance.
>
> -
>
> glenn wrote:
>
> Naftoli,
>
> I fixed my code per your comments and now I can edit and remove users
> from a list, as long as I populate the list with
> ModelView instances, as you said. As for the docs, this step was not
> clear to me at all. I just assumed that the list was
> just populated with User entities and the view in the ModelSnippet was
> instantiated with the selected User on each request.
>
> It sounds like your plate is pretty full, so I won't expect much, but
> sometime soon, could you provide an example, or improved
> docs, for using TableEditor and its related ItemsList trait.
>
> Thanks for all.
>
> Glenn...
>
> On Aug 5, 9:18 am, Naftoli Gugenheim  wrote:
>
> > Correction: ModelSnippet.load takes the actual Mapper instance, not the 
> > ModelView wrapper.
>
> > -
>
> > Naftoli Gugenheim wrote:
>
> > To answer your immediate question, the listing should not refer to the 
> > snippet's view but new ModelView instances for each entity. Then editAction 
> > is shorthand for the snippet's link method with a callback to call load on 
> > the ModelView. To set the snippet's view's entity, either call load on the 
> > snippet with the other ModelView, or call load on the other ModelView (or 
> > just set its entity directly).
> > As far as documentation, please tell me what scaladocs need what 
> > clarification. Thanks.
>
> > -
>
> > glenn wrote:
>
> > Naftoli,
>
> > Functional programming systems are notoriously difficult to document.
> > The only way to really know what's going on is to meticulously trace
> > through the source. But that requires
> > time-consuming trial and error coding. So, without clear examples
> > demonstrating exactly what you have in mind, I and others in the same
> > boat, could spend days and still not
> > get it right.
>
> > For example, I tried this:
>
> > var theUser:User = null
> > val view = new ModelView(theUser, this)
>
> >  def list(ns: NodeSeq): NodeSeq =  User.currentUser.map({user =>
> >         User.findAll.f

[Lift] Re: Where do I place a default.props file for use by Boot?

2009-08-05 Thread Tim Nelson
Try src/main/resources/props

On Wed, Aug 5, 2009 at 7:19 PM, Jeff McKenna  wrote:

>
> Newbee:
> I have a default.props file that I was able to read once.  I seem to
> have lost the incantation.
> Where do I put it.  I thought src/resouces would work.  But boot can
> not see to read the file.
> Any suggestions?
> >
>

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Where do I place a default.props file for use by Boot?

2009-08-05 Thread Jeff McKenna

Newbee:
I have a default.props file that I was able to read once.  I seem to
have lost the incantation.
Where do I put it.  I thought src/resouces would work.  But boot can
not see to read the file.
Any suggestions?
--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: New features

2009-08-05 Thread glenn

Naftoli,

While your working on this issue, there seems to be another. Here's
what's happening:

If I make a coding mistake, and code User as follows:

class User extends MegaProtoUser[User] with ManyToMany[Long,Role]{
  def getSingleton = User // what's the "meta" server

   object roles
extends MappedManyToMany(UserRole, UserRole.user, UserRole.role,
Role)


}

instead of

class User extends MegaProtoUser[User] with ManyToMany[LongUser]{ ...

I don't get a compiler error (I'm using Eclipse with the Scala
plugin). Instead,
I get a stack overflow error and my IDE crashes.

Glenn...


On Aug 5, 3:39 pm, Naftoli Gugenheim  wrote:
> Oh, I think I know what the problem is. I think I should classify it as a bug.
> Since you're adding a Role that isn't saved yet, and ManyToMany tracks the 
> children via the join table, it can't access the child. As a workaround save 
> the Role before adding it, although the need to do so is against the idea of 
> ManyToMany and OneToMany. I will see what I can do, G-d willing.
>
> -
>
> glenn wrote:
>
> Naftoli,
>
> Hate to do this to you, but I'm getting the following error using
> ManyToMany for Users to Roles:
>
> Message: java.lang.RuntimeException: Broken join
>         scala.Predef$.error(Predef.scala:76)
>         net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$
> $anonfun$apply$1.apply(ManyToMany.scala:54)
>         net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$
> $anonfun$apply$1.apply(ManyToMany.scala:54)
>         net.liftweb.util.EmptyBox.openOr(Box.scala:372)
>         net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children
> $1.apply(ManyToMany.scala:54)
>         net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children
> $1.apply(ManyToMany.scala:54)
>         scala.List.map(List.scala:812)
>         net.liftweb.mapper.ManyToMany$MappedManyToMany.children
> (ManyToMany.scala:54)
>         net.liftweb.mapper.ManyToMany$MappedManyToMany.elements
> (ManyToMany.scala:96)
>         scala.Seq$class.flatMap(Seq.scala:293)
>         net.liftweb.mapper.ManyToMany$MappedManyToMany.flatMap
> (ManyToMany.scala:44)
>
>  def edit(ns: NodeSeq): NodeSeq = {
>     val theUser = view.entity
>     val addRole = TheBindParam("insert", view.snippet.link("edit", ()
> => theUser.roles += new Role, Text(S?("Add Role"
>
>     bind("user", ns,
>          "firstname" -> text(theUser.firstName.is, theUser.firstName
> (_), ("size","20")),
>          "lastname" -> text(theUser.lastName.is,theUser.lastName(_),
> ("size", "30")),
>          "roles" -> theUser.roles.flatMap{role =>
>               bind("role", ns,
>                   "name" -> role.name.toForm,
>                   "remove" -> SHtml.submit(S?("Remove"), ()=>
> theUser.roles -= role)
>               )
>           },
>          addRole,
>          "submit" -> SHtml.submit(S?("Save"), ()=>view.save)
>          )
>     }
>
> The offending code seems to be the line: "roles" ->
> theUser.roles.flatMap{
> in the above bind method when I click on the addRole link.
>
> Here's my User class:
>
> class User extends MegaProtoUser[User] with ManyToMany[Long,User]{
>   def getSingleton = User // what's the "meta" server
>
>    object roles
>     extends MappedManyToMany(UserRole, UserRole.user, UserRole.role,
> Role)
>
> }
>
> What am I doing wrong? You can see how difficult it is to slog through
> this code, let alone just
> trying to explain the problem so I can get help.
>
> On Aug 5, 9:57 am, Naftoli Gugenheim  wrote:
>
> > I'll try.
> > By the way, as per my correction, you can implement list the regular way 
> > without ModelView, and just use ModelSnippet's load function in your edit 
> > link or button, passing it the User instance.
>
> > -
>
> > glenn wrote:
>
> > Naftoli,
>
> > I fixed my code per your comments and now I can edit and remove users
> > from a list, as long as I populate the list with
> > ModelView instances, as you said. As for the docs, this step was not
> > clear to me at all. I just assumed that the list was
> > just populated with User entities and the view in the ModelSnippet was
> > instantiated with the selected User on each request.
>
> > It sounds like your plate is pretty full, so I won't expect much, but
> > sometime soon, could you provide an example, or improved
> > docs, for using TableEditor and its related ItemsList trait.
>
> > Thanks for all.
>
> > Glenn...
>
> > On Aug 5, 9:18 am, Naftoli Gugenheim  wrote:
>
> > > Correction: ModelSnippet.load takes the actual Mapper instance, not the 
> > > ModelView wrapper.
>
> > > -
>
> > > Naftoli Gugenheim wrote:
>
> > > To answer your immediate question, the listing should not refer to the 
> > > snippet's view but new ModelView instances for each entity. Then 
> > > editAction is shorthand for the snippet's link method with a callback to 
> > > call load on the ModelView. To set the 

[Lift] Re: New features

2009-08-05 Thread Naftoli Gugenheim

Oh, I think I know what the problem is. I think I should classify it as a bug.
Since you're adding a Role that isn't saved yet, and ManyToMany tracks the 
children via the join table, it can't access the child. As a workaround save 
the Role before adding it, although the need to do so is against the idea of 
ManyToMany and OneToMany. I will see what I can do, G-d willing.


-
glenn wrote:


Naftoli,

Hate to do this to you, but I'm getting the following error using
ManyToMany for Users to Roles:

Message: java.lang.RuntimeException: Broken join
scala.Predef$.error(Predef.scala:76)
net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$
$anonfun$apply$1.apply(ManyToMany.scala:54)
net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$
$anonfun$apply$1.apply(ManyToMany.scala:54)
net.liftweb.util.EmptyBox.openOr(Box.scala:372)
net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children
$1.apply(ManyToMany.scala:54)
net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children
$1.apply(ManyToMany.scala:54)
scala.List.map(List.scala:812)
net.liftweb.mapper.ManyToMany$MappedManyToMany.children
(ManyToMany.scala:54)
net.liftweb.mapper.ManyToMany$MappedManyToMany.elements
(ManyToMany.scala:96)
scala.Seq$class.flatMap(Seq.scala:293)
net.liftweb.mapper.ManyToMany$MappedManyToMany.flatMap
(ManyToMany.scala:44)

 def edit(ns: NodeSeq): NodeSeq = {
val theUser = view.entity
val addRole = TheBindParam("insert", view.snippet.link("edit", ()
=> theUser.roles += new Role, Text(S?("Add Role"

bind("user", ns,
 "firstname" -> text(theUser.firstName.is, theUser.firstName
(_), ("size","20")),
 "lastname" -> text(theUser.lastName.is,theUser.lastName(_),
("size", "30")),
 "roles" -> theUser.roles.flatMap{role =>
  bind("role", ns,
  "name" -> role.name.toForm,
  "remove" -> SHtml.submit(S?("Remove"), ()=>
theUser.roles -= role)
  )
  },
 addRole,
 "submit" -> SHtml.submit(S?("Save"), ()=>view.save)
 )
}

The offending code seems to be the line: "roles" ->
theUser.roles.flatMap{
in the above bind method when I click on the addRole link.

Here's my User class:

class User extends MegaProtoUser[User] with ManyToMany[Long,User]{
  def getSingleton = User // what's the "meta" server

   object roles
extends MappedManyToMany(UserRole, UserRole.user, UserRole.role,
Role)

}

What am I doing wrong? You can see how difficult it is to slog through
this code, let alone just
trying to explain the problem so I can get help.

On Aug 5, 9:57 am, Naftoli Gugenheim  wrote:
> I'll try.
> By the way, as per my correction, you can implement list the regular way 
> without ModelView, and just use ModelSnippet's load function in your edit 
> link or button, passing it the User instance.
>
> -
>
> glenn wrote:
>
> Naftoli,
>
> I fixed my code per your comments and now I can edit and remove users
> from a list, as long as I populate the list with
> ModelView instances, as you said. As for the docs, this step was not
> clear to me at all. I just assumed that the list was
> just populated with User entities and the view in the ModelSnippet was
> instantiated with the selected User on each request.
>
> It sounds like your plate is pretty full, so I won't expect much, but
> sometime soon, could you provide an example, or improved
> docs, for using TableEditor and its related ItemsList trait.
>
> Thanks for all.
>
> Glenn...
>
> On Aug 5, 9:18 am, Naftoli Gugenheim  wrote:
>
> > Correction: ModelSnippet.load takes the actual Mapper instance, not the 
> > ModelView wrapper.
>
> > -
>
> > Naftoli Gugenheim wrote:
>
> > To answer your immediate question, the listing should not refer to the 
> > snippet's view but new ModelView instances for each entity. Then editAction 
> > is shorthand for the snippet's link method with a callback to call load on 
> > the ModelView. To set the snippet's view's entity, either call load on the 
> > snippet with the other ModelView, or call load on the other ModelView (or 
> > just set its entity directly).
> > As far as documentation, please tell me what scaladocs need what 
> > clarification. Thanks.
>
> > -
>
> > glenn wrote:
>
> > Naftoli,
>
> > Functional programming systems are notoriously difficult to document.
> > The only way to really know what's going on is to meticulously trace
> > through the source. But that requires
> > time-consuming trial and error coding. So, without clear examples
> > demonstrating exactly what you have in mind, I and others in the same
> > boat, could spend days and still not
> > get it right.
>
> > For example, I tried this:
>
> > var theUser:User = null
> > val view = new ModelView(theUser, t

[Lift] Re: New features

2009-08-05 Thread Naftoli Gugenheim

First of all, let me tell you what the error means. It means that there is a 
relevant row in the join table that doesn't have a corresponding element in the 
other table. Specifically, calling joinRecord.childMappedForeignKey.obj, so to 
speak, returns Empty.
The question is how it got to this inconsistent state. When you add a Role to a 
User, MappedManyToMany creates a UserRole for it. For some reason though there 
is a UserRole without a Role or User.
Can you send me a self-contained project? Also is it high priority?

-
glenn wrote:


Naftoli,

Hate to do this to you, but I'm getting the following error using
ManyToMany for Users to Roles:

Message: java.lang.RuntimeException: Broken join
scala.Predef$.error(Predef.scala:76)
net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$
$anonfun$apply$1.apply(ManyToMany.scala:54)
net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$
$anonfun$apply$1.apply(ManyToMany.scala:54)
net.liftweb.util.EmptyBox.openOr(Box.scala:372)
net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children
$1.apply(ManyToMany.scala:54)
net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children
$1.apply(ManyToMany.scala:54)
scala.List.map(List.scala:812)
net.liftweb.mapper.ManyToMany$MappedManyToMany.children
(ManyToMany.scala:54)
net.liftweb.mapper.ManyToMany$MappedManyToMany.elements
(ManyToMany.scala:96)
scala.Seq$class.flatMap(Seq.scala:293)
net.liftweb.mapper.ManyToMany$MappedManyToMany.flatMap
(ManyToMany.scala:44)

 def edit(ns: NodeSeq): NodeSeq = {
val theUser = view.entity
val addRole = TheBindParam("insert", view.snippet.link("edit", ()
=> theUser.roles += new Role, Text(S?("Add Role"

bind("user", ns,
 "firstname" -> text(theUser.firstName.is, theUser.firstName
(_), ("size","20")),
 "lastname" -> text(theUser.lastName.is,theUser.lastName(_),
("size", "30")),
 "roles" -> theUser.roles.flatMap{role =>
  bind("role", ns,
  "name" -> role.name.toForm,
  "remove" -> SHtml.submit(S?("Remove"), ()=>
theUser.roles -= role)
  )
  },
 addRole,
 "submit" -> SHtml.submit(S?("Save"), ()=>view.save)
 )
}

The offending code seems to be the line: "roles" ->
theUser.roles.flatMap{
in the above bind method when I click on the addRole link.

Here's my User class:

class User extends MegaProtoUser[User] with ManyToMany[Long,User]{
  def getSingleton = User // what's the "meta" server

   object roles
extends MappedManyToMany(UserRole, UserRole.user, UserRole.role,
Role)

}

What am I doing wrong? You can see how difficult it is to slog through
this code, let alone just
trying to explain the problem so I can get help.

On Aug 5, 9:57 am, Naftoli Gugenheim  wrote:
> I'll try.
> By the way, as per my correction, you can implement list the regular way 
> without ModelView, and just use ModelSnippet's load function in your edit 
> link or button, passing it the User instance.
>
> -
>
> glenn wrote:
>
> Naftoli,
>
> I fixed my code per your comments and now I can edit and remove users
> from a list, as long as I populate the list with
> ModelView instances, as you said. As for the docs, this step was not
> clear to me at all. I just assumed that the list was
> just populated with User entities and the view in the ModelSnippet was
> instantiated with the selected User on each request.
>
> It sounds like your plate is pretty full, so I won't expect much, but
> sometime soon, could you provide an example, or improved
> docs, for using TableEditor and its related ItemsList trait.
>
> Thanks for all.
>
> Glenn...
>
> On Aug 5, 9:18 am, Naftoli Gugenheim  wrote:
>
> > Correction: ModelSnippet.load takes the actual Mapper instance, not the 
> > ModelView wrapper.
>
> > -
>
> > Naftoli Gugenheim wrote:
>
> > To answer your immediate question, the listing should not refer to the 
> > snippet's view but new ModelView instances for each entity. Then editAction 
> > is shorthand for the snippet's link method with a callback to call load on 
> > the ModelView. To set the snippet's view's entity, either call load on the 
> > snippet with the other ModelView, or call load on the other ModelView (or 
> > just set its entity directly).
> > As far as documentation, please tell me what scaladocs need what 
> > clarification. Thanks.
>
> > -
>
> > glenn wrote:
>
> > Naftoli,
>
> > Functional programming systems are notoriously difficult to document.
> > The only way to really know what's going on is to meticulously trace
> > through the source. But that requires
> > time-consuming trial and error coding. So, without clear examples
> > demonstrating exactly what you have in mind, I and others in the same
> > boat, 

[Lift] Re: Asynchronous Javascript problem

2009-08-05 Thread Channing Walton

ok I've done that: git://github.com/channingwalton/lift_1_1_sample.git

run the app up and go to http://localhost:8080/mapSearch and try the
search. I find stack overflow in Safari 4.0.2, and Opera 9.64. The
query works in Firefox 3.5.2 and Webkit Version 4.0.2 (5530.19,
r46770) (latest nightly) - all OS X

I haven't been able to test on windows yet.
--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: New features

2009-08-05 Thread glenn

Naftoli,

Hate to do this to you, but I'm getting the following error using
ManyToMany for Users to Roles:

Message: java.lang.RuntimeException: Broken join
scala.Predef$.error(Predef.scala:76)
net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$
$anonfun$apply$1.apply(ManyToMany.scala:54)
net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$
$anonfun$apply$1.apply(ManyToMany.scala:54)
net.liftweb.util.EmptyBox.openOr(Box.scala:372)
net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children
$1.apply(ManyToMany.scala:54)
net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children
$1.apply(ManyToMany.scala:54)
scala.List.map(List.scala:812)
net.liftweb.mapper.ManyToMany$MappedManyToMany.children
(ManyToMany.scala:54)
net.liftweb.mapper.ManyToMany$MappedManyToMany.elements
(ManyToMany.scala:96)
scala.Seq$class.flatMap(Seq.scala:293)
net.liftweb.mapper.ManyToMany$MappedManyToMany.flatMap
(ManyToMany.scala:44)

 def edit(ns: NodeSeq): NodeSeq = {
val theUser = view.entity
val addRole = TheBindParam("insert", view.snippet.link("edit", ()
=> theUser.roles += new Role, Text(S?("Add Role"

bind("user", ns,
 "firstname" -> text(theUser.firstName.is, theUser.firstName
(_), ("size","20")),
 "lastname" -> text(theUser.lastName.is,theUser.lastName(_),
("size", "30")),
 "roles" -> theUser.roles.flatMap{role =>
  bind("role", ns,
  "name" -> role.name.toForm,
  "remove" -> SHtml.submit(S?("Remove"), ()=>
theUser.roles -= role)
  )
  },
 addRole,
 "submit" -> SHtml.submit(S?("Save"), ()=>view.save)
 )
}

The offending code seems to be the line: "roles" ->
theUser.roles.flatMap{
in the above bind method when I click on the addRole link.

Here's my User class:

class User extends MegaProtoUser[User] with ManyToMany[Long,User]{
  def getSingleton = User // what's the "meta" server

   object roles
extends MappedManyToMany(UserRole, UserRole.user, UserRole.role,
Role)

}

What am I doing wrong? You can see how difficult it is to slog through
this code, let alone just
trying to explain the problem so I can get help.

On Aug 5, 9:57 am, Naftoli Gugenheim  wrote:
> I'll try.
> By the way, as per my correction, you can implement list the regular way 
> without ModelView, and just use ModelSnippet's load function in your edit 
> link or button, passing it the User instance.
>
> -
>
> glenn wrote:
>
> Naftoli,
>
> I fixed my code per your comments and now I can edit and remove users
> from a list, as long as I populate the list with
> ModelView instances, as you said. As for the docs, this step was not
> clear to me at all. I just assumed that the list was
> just populated with User entities and the view in the ModelSnippet was
> instantiated with the selected User on each request.
>
> It sounds like your plate is pretty full, so I won't expect much, but
> sometime soon, could you provide an example, or improved
> docs, for using TableEditor and its related ItemsList trait.
>
> Thanks for all.
>
> Glenn...
>
> On Aug 5, 9:18 am, Naftoli Gugenheim  wrote:
>
> > Correction: ModelSnippet.load takes the actual Mapper instance, not the 
> > ModelView wrapper.
>
> > -
>
> > Naftoli Gugenheim wrote:
>
> > To answer your immediate question, the listing should not refer to the 
> > snippet's view but new ModelView instances for each entity. Then editAction 
> > is shorthand for the snippet's link method with a callback to call load on 
> > the ModelView. To set the snippet's view's entity, either call load on the 
> > snippet with the other ModelView, or call load on the other ModelView (or 
> > just set its entity directly).
> > As far as documentation, please tell me what scaladocs need what 
> > clarification. Thanks.
>
> > -
>
> > glenn wrote:
>
> > Naftoli,
>
> > Functional programming systems are notoriously difficult to document.
> > The only way to really know what's going on is to meticulously trace
> > through the source. But that requires
> > time-consuming trial and error coding. So, without clear examples
> > demonstrating exactly what you have in mind, I and others in the same
> > boat, could spend days and still not
> > get it right.
>
> > For example, I tried this:
>
> > var theUser:User = null
> > val view = new ModelView(theUser, this)
>
> >  def list(ns: NodeSeq): NodeSeq =  User.currentUser.map({user =>
> >         User.findAll.flatMap({u =>
> >             bind("user", chooseTemplate("user", "entry", ns),
> >                  "firstname" -> Text(u.firstName.is),
> >                  "lastname" -> Text(u.lastName.is),
> >                  "email" -> Text(u.email.is),
> >                  "roles" -> u.roles.map(_.name.toString).mkString(",
> > "),
> >  

[Lift] Re: More than one in HTML file

2009-08-05 Thread Timothy Perrett

Marius is right, use with-param... That's the correct solution here.

Cheers, Tim


On 05/08/2009 22:19, "pabraham"  wrote:

> 
> I've added  to my index.html file and now get:
> 
> XML Parsing Error: junk after document element
> Location: http://192.168.96.150:8080/
> Line Number 113, Column 1:http://liftweb.net/";
> xmlns="http://www.w3.org/1999/xhtml";>
> ^
> 
> Any ideas?
> 
> In the meantime I can look at .
> 
> Paul.
> 
> On 5 Aug, 22:08, Naftoli Gugenheim  wrote:
>> XML documents need to have a single top-level element. Surround the whole
>> index.html with lift:children.
>> 
>> -
>> 
>> pabraham wrote:
>> 
>> Hello there,
>> 
>> Is it possible for an HTML file to have more than one lift:surround
>> tag?
>> 
>> For example, default.html contains
>> 
>> ...
>> 
>> ...
>> 
>> ...
>> 
>> My index.html contains
>> 
>> 
>>   This is some content
>> 
>> 
>>   This is some content in the sidebar
>> 
>> 
>> From my fruitless attempts, it seems that the answer to my question is
>> no, but is there any way that I can get this sort of thing to work?
>> 
>> Thanks.
>> 
>> Paul.
> 
> > 
> 



--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Eclipse setup

2009-08-05 Thread Miles Sabin

On Wed, Aug 5, 2009 at 10:39 PM, Steffen
Weißmann wrote:
>> Can you show me the contents of your .project and .classpath files.
>
> Both files attached. Thanks for looking into it...

OK, you have two problem here (which are Scala IDE bugs, so I was a
bit harsh on Maven this time around).

You have two output folders: the Scala IDE <= 2.7.5.final only
supports one. Use a single default output folder.

You also have source directories nested below the top level of your
project. Although I've seen reports that this works from various
people, there's code in 2.7.5.final and earlier which makes this
unlikely. If switching to a single output folder doesn't solve your
problems try also moving your source directories to the top level.

Both of these issues are fixed on trunk (but don't go there unless
you're using the Lift 2.8.0 branch).

Let me know how you get on ...

Cheers,


Miles

-- 
Miles Sabin
tel: +44 (0)7813 944 528
skype:  milessabin
http://www.chuusai.com/
http://twitter.com/milessabin

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Exception for S.? while booting

2009-08-05 Thread Naftoli Gugenheim

I just read the scaladoc comment of S.init. Does it have anything to do with 
this subject?

-
Heiko Seeberger wrote:

Ah, yes!Sorry, I did not get the point, but obviously the val is to be
blamed ;-)
Now it's running, thanx!!!

Heiko

2009/8/5 marius d. 

>
> I'm aware about the override thing but I don't see why you would do it
> in such way. Since you don't have state, you don't have a session =>
> you don't have S. Are you using a statelesDispatchPf ?
>
> You can do:
>
> 1. Use your own ResourceBundles
> 2. Or a hacky thingy like:
>
> val session = LiftRules.getLiftSession(request, httpRequest)
> S.initIfUninitted(session) {
>   // Now you should be able to call call S.?(...)
> }
>
> Localization is "bound" to state as ResourceBundles
>
> You exception thrown in Boot probably was cause because you used a val
> and it obviously tried to initialize it. Using a def or lazy val it
> would be evaluated properly upon requests.
>
> Typically S.? is used in the context of page rendering, Ajax functions
> processing, DispatchPF. All these are executed in a stateful context
> where S is available. To process pure stateless requests you have
> LiftRules.statelessDispatchTable, and a few request processing
> hooks ... but do you really need those?
>
> Do you have a usecase when you want to process a pure stateless
> requests and need Lift's localization?
>
> Br's,
> Marius
>
> On Aug 5, 8:50 am, Heiko Seeberger 
> wrote:
> > def can be overridden with val. But this is a Scala thingy, please do not
> > bother. If it makes you easier replace val with def.
> > The question remains: How can i18n be done in "stateless" (request state)
> > cases?
> >
> > 2009/8/5 marius d. 
> >
> >
> >
> >
> >
> > > I thought validations is a function not a val:
> >
> > > override val validations should probably be
> >
> > > override def validations ?
> >
> > > or
> >
> > > override lazy val validations ?
> >
> > > Br's,
> > > Marius
> >
> > > On Aug 5, 7:48 am, Heiko Seeberger 
> > > wrote:
> > > > I would like to internationalize my code. Something like:
> > > > Mapper class:
> >
> > > > class Course
> > > >   extends LongKeyedMapper[Course]
> > > >   with IdPK {
> >
> > > >   ...
> >
> > > > override val validations =
> > > >   valMinLen(3, ?("minLen", 3)) _ ::
> > > >   valMaxLen(50, ?("maxLen", 50)) _ ::
> > > >   Nil
> > > >   }
> >
> > > > Localized messages:
> >
> > > > minLen=At least %s characters required!
> > > > maxLen=At most %s characters allowed!
> >
> > > > Thanx
> > > > Heiko
> >
> > > > 2009/8/4 marius d. 
> >
> > > > > S lifetime is per request. S is not constructed on Boot. Could you
> > > > > post a code snippet on what you're trying to achieve?
> >
> > > > > Br's,
> > > > > Marius
> >
> > > > > On Aug 4, 12:43 pm, Heiko Seeberger <
> heiko.seeber...@googlemail.com>
> > > > > wrote:
> > > > > > Hi,
> >
> > > > > > When I try to use internationalization via S.? in a Mapper class,
> I
> > > get
> > > > > the
> > > > > > below exception while booting Lift. It seems that S._resBundle is
> > > null
> > > > > when
> > > > > > Schemifier tries to do its work.
> >
> > > > > > Is this a bug or a feature (S must not be used outside the
> request
> > > life
> > > > > > cycle). If last, how to i18n then?
> >
> > > > > > Thanx
> > > > > > Heiko
> >
> > > > > > 0 [main] ERROR lift - Failed to Boot
> > > > > > java.lang.ExceptionInInitializerError
> > > > > > at bootstrap.liftweb.Boot.boot(Boot.scala:38)
> > > > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> > > > > > at
> >
> > >
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> > > > > > at
> >
> > >
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> > > > > > at java.lang.reflect.Method.invoke(Method.java:585)
> > > > > > at
> >
> > >
> net.liftweb.util.ClassHelpers$$anonfun$createInvoker$1.apply(ClassHelpers.scala:408)
> > > > > > at
> >
> > >
> net.liftweb.util.ClassHelpers$$anonfun$createInvoker$1.apply(ClassHelpers.scala:406)
> > > > > > at
> >
> > >
> net.liftweb.http.DefaultBootstrap$$anonfun$boot$1.apply(LiftRules.scala:1096)
> > > > > > at
> >
> > >
> net.liftweb.http.DefaultBootstrap$$anonfun$boot$1.apply(LiftRules.scala:1096)
> > > > > > at net.liftweb.util.Full.map(Box.scala:330)
> > > > > > at net.liftweb.http.DefaultBootstrap$.boot(LiftRules.scala:1096)
> > > > > > at net.liftweb.http.LiftFilter.bootLift(LiftServlet.scala:560)
> > > > > > at net.liftweb.http.LiftFilter.init(LiftServlet.scala:534)
> > > > > > at
> > > org.mortbay.jetty.servlet.FilterHolder.doStart(FilterHolder.java:97)
> > > > > > at
> >
> > >
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
> > > > > > at
> >
> > >
> org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:653)
> > > > > > at
> org.mortbay.jetty.servlet.Context.startContext(Context.java:140)
> > > > > > at
> >
> > >
> org.mortbay.jetty.webapp.WebA

[Lift] Re: Eclipse setup

2009-08-05 Thread Steffen Weißmann
> Can you show me the contents of your .project and .classpath files.

Both files attached. Thanks for looking into it...

On Wed, Aug 5, 2009 at 11:34 PM, Miles Sabin wrote:
>
> On Wed, Aug 5, 2009 at 10:21 PM,
> steffen.weissmann wrote:
>> I have trouble with getting started with lift in eclipse. In my
>> project, created from lift-archetype-basic 1.1-SNAPSHOT, i have all
>> the lift jars with attached sources (all in the maven repository)
>> under "Referenced Libraries". I can also browse the source code by
>> double-clicking on the classes there, but i have no code completion
>> for many of these classes. Sometimes when Ctrl-clicking on a Scala
>> type it opens Object.java source... What I am using is Eclipse Galileo
>> with Scala plugin 2.7.5.
>
> This sounds like Maven breakage yet again.
>
> Can you show me the contents of your .project and .classpath files.
>
> Cheers,
>
>
> Miles
>
> --
> Miles Sabin
> tel: +44 (0)7813 944 528
> skype:  milessabin
> http://www.chuusai.com/
> http://twitter.com/milessabin
>
> >
>



-- 
Steffen Weissmann

Technische Universitaet Berlin - Math. Department - MA 3-2

Str. des 17. Juni 136
10623 Berlin - Germany

Phone: +49 30 314-29278
Mail: weissm...@math.tu-berlin.de
Web: www.math.tu-berlin.de/~weissman

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



.classpath
Description: Binary data


.project
Description: Binary data


[Lift] Re: Eclipse setup

2009-08-05 Thread Miles Sabin

On Wed, Aug 5, 2009 at 10:21 PM,
steffen.weissmann wrote:
> I have trouble with getting started with lift in eclipse. In my
> project, created from lift-archetype-basic 1.1-SNAPSHOT, i have all
> the lift jars with attached sources (all in the maven repository)
> under "Referenced Libraries". I can also browse the source code by
> double-clicking on the classes there, but i have no code completion
> for many of these classes. Sometimes when Ctrl-clicking on a Scala
> type it opens Object.java source... What I am using is Eclipse Galileo
> with Scala plugin 2.7.5.

This sounds like Maven breakage yet again.

Can you show me the contents of your .project and .classpath files.

Cheers,


Miles

-- 
Miles Sabin
tel: +44 (0)7813 944 528
skype:  milessabin
http://www.chuusai.com/
http://twitter.com/milessabin

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Eclipse setup

2009-08-05 Thread steffen.weissmann

I have trouble with getting started with lift in eclipse. In my
project, created from lift-archetype-basic 1.1-SNAPSHOT, i have all
the lift jars with attached sources (all in the maven repository)
under "Referenced Libraries". I can also browse the source code by
double-clicking on the classes there, but i have no code completion
for many of these classes. Sometimes when Ctrl-clicking on a Scala
type it opens Object.java source... What I am using is Eclipse Galileo
with Scala plugin 2.7.5.

Thanks for any suggestions...

Steffen.

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: More than one in HTML file

2009-08-05 Thread Naftoli Gugenheim

Which browser gives that error? What do you see in View Source?

-
pabraham wrote:


I've added  to my index.html file and now get:

XML Parsing Error: junk after document element
Location: http://192.168.96.150:8080/
Line Number 113, Column 1:http://liftweb.net/";
xmlns="http://www.w3.org/1999/xhtml";>
^

Any ideas?

In the meantime I can look at .

Paul.

On 5 Aug, 22:08, Naftoli Gugenheim  wrote:
> XML documents need to have a single top-level element. Surround the whole 
> index.html with lift:children.
>
> -
>
> pabraham wrote:
>
> Hello there,
>
> Is it possible for an HTML file to have more than one lift:surround
> tag?
>
> For example, default.html contains
>
> ...
> 
> ...
> 
> ...
>
> My index.html contains
>
> 
>   This is some content
> 
> 
>   This is some content in the sidebar
> 
>
> From my fruitless attempts, it seems that the answer to my question is
> no, but is there any way that I can get this sort of thing to work?
>
> Thanks.
>
> Paul.



--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: More than one in HTML file

2009-08-05 Thread pabraham

I've added  to my index.html file and now get:

XML Parsing Error: junk after document element
Location: http://192.168.96.150:8080/
Line Number 113, Column 1:http://liftweb.net/";
xmlns="http://www.w3.org/1999/xhtml";>
^

Any ideas?

In the meantime I can look at .

Paul.

On 5 Aug, 22:08, Naftoli Gugenheim  wrote:
> XML documents need to have a single top-level element. Surround the whole 
> index.html with lift:children.
>
> -
>
> pabraham wrote:
>
> Hello there,
>
> Is it possible for an HTML file to have more than one lift:surround
> tag?
>
> For example, default.html contains
>
> ...
> 
> ...
> 
> ...
>
> My index.html contains
>
> 
>   This is some content
> 
> 
>   This is some content in the sidebar
> 
>
> From my fruitless attempts, it seems that the answer to my question is
> no, but is there any way that I can get this sort of thing to work?
>
> Thanks.
>
> Paul.

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: More than one in HTML file

2009-08-05 Thread Naftoli Gugenheim

XML documents need to have a single top-level element. Surround the whole 
index.html with lift:children.

-
pabraham wrote:


Hello there,

Is it possible for an HTML file to have more than one lift:surround
tag?

For example, default.html contains

...

...

...

My index.html contains


  This is some content


  This is some content in the sidebar


>From my fruitless attempts, it seems that the answer to my question is
no, but is there any way that I can get this sort of thing to work?

Thanks.

Paul.



--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: More than one in HTML file

2009-08-05 Thread marius d.

No. Each template must be xml well formed so you can not have more
then one root element,

Please see  to handle multiple binds.

Br;s,
Marius

On Aug 6, 12:04 am, pabraham  wrote:
> Hello there,
>
> Is it possible for an HTML file to have more than one lift:surround
> tag?
>
> For example, default.html contains
>
> ...
> 
> ...
> 
> ...
>
> My index.html contains
>
> 
>   This is some content
> 
> 
>   This is some content in the sidebar
> 
>
> From my fruitless attempts, it seems that the answer to my question is
> no, but is there any way that I can get this sort of thing to work?
>
> Thanks.
>
> Paul.
--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] More than one in HTML file

2009-08-05 Thread pabraham

Hello there,

Is it possible for an HTML file to have more than one lift:surround
tag?

For example, default.html contains

...

...

...

My index.html contains


  This is some content


  This is some content in the sidebar


>From my fruitless attempts, it seems that the answer to my question is
no, but is there any way that I can get this sort of thing to work?

Thanks.

Paul.

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Code review for some Mailer enhancements

2009-08-05 Thread David Pollak
Spencer,

I've taken your suggestions and rolled them into Lift... see the enclosed
diff.

Thanks for making the suggestion.

David

On Wed, Jul 8, 2009 at 3:29 PM, Spencer Uresk  wrote:

>
> As I alluded to in another email, the way Lift's Mailer class works
> causes some problems when deploying to Tomcat (or any environment
> where you have multiple applications) due to it relying on System
> properties for most of the configuration. As I'm still trying to wrap
> my head around both Lift and Scala, I thought it would be a fun
> exercise to try and enhance Mailer to allow more flexible configuration.
>
> If anyone has a few minutes, I'd appreciate a review of my code and
> the approach I took. If it is good and useful enough, I hope you'll
> consider accepting a patch to add these features back into Lift.
>
> So, the idea I had was to allow configuration via JNDI or via a simple
> property map. The session lookup function would first try to get a
> session via JNDI, if that doesn't work, it will look to see if there
> are custom properties to set, otherwise it just uses the default
> system properties (which is how it works now).
>
> One feature I added that I'm not 100% sure about is if there is an
> exception when looking up the JNDI reference, it swallows the
> exception and returns Empty so that custom/default properties can be
> used. This would allow you to use JNDI in production, but a simple
> property map in development. This is a nice convenience feature, but
> it could potentially hide production errors (although the exception is
> logged).
>
> Here are the pieces of Mailer I changed/addded:
>
>   var authenticator: Box[Authenticator] = Empty
>
>   var jndiName: Box[String] = Empty
>
>   var customProperties: Box[Map[String, String]] = Empty
>
>   private def getJndiSession: Box[Session] = jndiName match {
> case Full(jndiSessionName) =>
>   var session: Box[Session] = Empty
>
>   try {
> val context: Context = new InitialContext().lookup("java:comp/
> env").asInstanceOf[Context];
> session =
> Full(context.lookup(jndiSessionName).asInstanceOf[Session])
>   } catch {
> case e: Exception => Log.error("Cannot lookup session from
> JNDI", e)
>   }
>
>   session
> case _ => Empty
>   }
>
>   def session: Session = {
> val session = getJndiSession match {
>   case Full(jndiSession) => jndiSession
>   case _ => authenticator match {
> case Full(a) => Session.getInstance(buildProps, a)
> case _ => Session.getInstance(buildProps)
>   }
> }
>
> session
>   }
>
>
>   def buildProps: Properties = {
> val p = System.getProperties.clone.asInstanceOf[Properties]
>
> customProperties match {
>   case Full(customProperties) =>
> {customProperties.keys.foreach{key => p.put(key,
> customProperties(key))}}
>   case _ =>
> }
>
> p
>   }
>
>
> ===
>
> And here is how you would configure the mailer in your Boot class:
>
> // Using custom properties
> val mailProps: Map[String, String] = Map("mail.smtp.starttls.enable" -
>  > "true", "mail.smtp.host" -> "smtp.gmail.com", "mail.smtp.auth" ->
> "true", "mail.smtp.port" -> "587")
> SuperMailer.customProperties = Full(mailProps)
>
> // Using JNDI
> SuperMailer.jndiName = "mail/Session"
>
> ===
>
> I still need to do a little more testing, but everything seems to be
> working ok. I'd appreciate any feedback on the code.
>
> Thanks,
>
> - Spencer
>
> >
>


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

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---

diff --git a/lift-util/src/main/scala/net/liftweb/util/Mailer.scala 
b/lift-util/src/main/scala/net/liftweb/util/Mailer.scala
index e1a4742..2ed4d8d 100644
--- a/lift-util/src/main/scala/net/liftweb/util/Mailer.scala
+++ b/lift-util/src/main/scala/net/liftweb/util/Mailer.scala
@@ -18,6 +18,8 @@ import _root_.scala.actors._
 import Actor._
 import _root_.javax.mail._
 import _root_.javax.mail.internet._
+import _root_.javax.naming.{Context, InitialContext}
+import _root_.java.util.Properties
 
 /**
  * Utilities for sending email.
@@ -67,6 +69,31 @@ object Mailer {
   var authenticator: Box[Authenticator] = Empty
 
   /**
+   * Use the mailer resource in your container by specifying the JNDI name
+   */
+  var jndiName: Box[String] = Empty
+
+  /**
+   * Custom properties for the JNDI session
+   */
+  var customProperties: Map[String, String] = Map()
+
+  lazy val jndiSession: Box[Session] =

[Lift] Comet render and jQuery

2009-08-05 Thread Avo Reid

I am might be going about this in the wrong way but I wanted to get
confirmation.

I have a comet lift snippet that waits for a comet actor to send down
search results triggered by a button click after entering keywords.



Loading...
 

In the actor I rendor the search results and merge an onclick function
into the header document.ready.  Things seem to work fine but after
the snippet renders the onclick function does not activate until I
click on 2 hyperlinks, which takes me to the linked website (click
url) then hitting the back button back to the liftwebsite, basically
reloading the page twice.  After this the alert box shows up for each
hyperlink.

I can refactor this to work in a different way but I wanted to
understand what is wrong here if anyone knows.

Thanks in advance


def render = {
def searchResultFormatter(itemToFormat: SearchResultSet): NodeSeq
= {
  
  
  
{itemToFormat.resultSetItem.title}
  
  
  
  {itemToFormat.resultSetItem.summary}
  
 }
bind("SearchResults" -> {searchLinks.flatMap
(resultFormatter _)}


{Unparsed
("""
 jQuery(document).ready(function() {
$('.searchlink').click(function() {
 alert('call made it here');
 return (false);
 });
  })
 """)}
)

  }

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Prepare StatefulSnippet in advance

2009-08-05 Thread Naftoli Gugenheim

Okay, that makes sense! I guess it's generated during the xml processing stage?

-
David Pollak wrote:

On Wed, Aug 5, 2009 at 1:25 PM, Naftoli Gugenheim wrote:

>
> I have working now by instantiating a client snippet class and calling
> S.mapSnippet with the snippet's edit method. But why didn't it work by
> calling its registerThisSnippet method?


because the snippet didn't know its name.


>
>
> -
> David Pollak wrote:
>
> Create a top-level RequestVar:
>
> object TheClient extends RequestVar[Box[Client]](Empty)
> object ReturnToMe extends RequestVar[Box[() => Unit]](Empty)
>
> class ClientEditor extends StatefulSnippet {
>  val referer = S.referer openOr "/"
>  val client = TheClient.is openOr {S.error("client not provided");
> S.redirectTo(referer)}
>  val goBackFunc = ReturnToMe.is
>
>  ... stuff here
>
>  when done:
>
>  goBackFunc.map(_.apply())
>  S.redirectTo(referer)
> }
>
> So, your link to this page will contain a function that looks like:
>
> {TheClient(Full(client)); ReturnToMe(Full({S.redirecTo(the from page, () =>
> {re-associate your stateful snippet})}))}
>
>
> On Wed, Aug 5, 2009 at 1:07 PM, Naftoli Gugenheim  >wrote:
>
> >
> > I don't have code available to post right now, but let me try to explain
> > better.
> > Basically you're editing a request, which is associated with a client.
> Now
> > when your entering the request you may notice that the client's info is
> > wrong. So I need a link to the client editing page, which is
> StatefulSnippet
> > based. However, when that page loads it has to use an instance of the
> > snippet that knows which client I want to edit.
> >
> > -
> > David Pollak wrote:
> >
> > Please provide a complete (executable) code sample so I can understand
> the
> > flow.
> >
> > On Wed, Aug 5, 2009 at 9:40 AM, Naftoli Gugenheim  > >wrote:
> >
> > >
> > > Hi. I have one screen, /requests/edit, that links to /clients/edit, in
> > > order to edit a specific client. Both use StatefulSnippet. In the link
> I
> > > specify a function that instantiates and registers an instance of that
> > > StatefulSnippet. However the page does not use that instance but a new
> > > instance instead. What am I doing wrong?
> > > Thanks.
> > >
> > >
> > > >
> > >
> >
> >
> > --
> > Lift, the simply functional web framework http://liftweb.net
> > Beginning Scala http://www.apress.com/book/view/1430219890
> > Follow me: http://twitter.com/dpp
> > Git some: http://github.com/dpp
> >
> >
> >
> > >
> >
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Git some: http://github.com/dpp
>
>
>
> >
>


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



--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Prepare StatefulSnippet in advance

2009-08-05 Thread David Pollak
On Wed, Aug 5, 2009 at 1:25 PM, Naftoli Gugenheim wrote:

>
> I have working now by instantiating a client snippet class and calling
> S.mapSnippet with the snippet's edit method. But why didn't it work by
> calling its registerThisSnippet method?


because the snippet didn't know its name.


>
>
> -
> David Pollak wrote:
>
> Create a top-level RequestVar:
>
> object TheClient extends RequestVar[Box[Client]](Empty)
> object ReturnToMe extends RequestVar[Box[() => Unit]](Empty)
>
> class ClientEditor extends StatefulSnippet {
>  val referer = S.referer openOr "/"
>  val client = TheClient.is openOr {S.error("client not provided");
> S.redirectTo(referer)}
>  val goBackFunc = ReturnToMe.is
>
>  ... stuff here
>
>  when done:
>
>  goBackFunc.map(_.apply())
>  S.redirectTo(referer)
> }
>
> So, your link to this page will contain a function that looks like:
>
> {TheClient(Full(client)); ReturnToMe(Full({S.redirecTo(the from page, () =>
> {re-associate your stateful snippet})}))}
>
>
> On Wed, Aug 5, 2009 at 1:07 PM, Naftoli Gugenheim  >wrote:
>
> >
> > I don't have code available to post right now, but let me try to explain
> > better.
> > Basically you're editing a request, which is associated with a client.
> Now
> > when your entering the request you may notice that the client's info is
> > wrong. So I need a link to the client editing page, which is
> StatefulSnippet
> > based. However, when that page loads it has to use an instance of the
> > snippet that knows which client I want to edit.
> >
> > -
> > David Pollak wrote:
> >
> > Please provide a complete (executable) code sample so I can understand
> the
> > flow.
> >
> > On Wed, Aug 5, 2009 at 9:40 AM, Naftoli Gugenheim  > >wrote:
> >
> > >
> > > Hi. I have one screen, /requests/edit, that links to /clients/edit, in
> > > order to edit a specific client. Both use StatefulSnippet. In the link
> I
> > > specify a function that instantiates and registers an instance of that
> > > StatefulSnippet. However the page does not use that instance but a new
> > > instance instead. What am I doing wrong?
> > > Thanks.
> > >
> > >
> > > >
> > >
> >
> >
> > --
> > Lift, the simply functional web framework http://liftweb.net
> > Beginning Scala http://www.apress.com/book/view/1430219890
> > Follow me: http://twitter.com/dpp
> > Git some: http://github.com/dpp
> >
> >
> >
> > >
> >
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Git some: http://github.com/dpp
>
>
>
> >
>


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

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Prepare StatefulSnippet in advance

2009-08-05 Thread Naftoli Gugenheim

I have working now by instantiating a client snippet class and calling 
S.mapSnippet with the snippet's edit method. But why didn't it work by calling 
its registerThisSnippet method?

-
David Pollak wrote:

Create a top-level RequestVar:

object TheClient extends RequestVar[Box[Client]](Empty)
object ReturnToMe extends RequestVar[Box[() => Unit]](Empty)

class ClientEditor extends StatefulSnippet {
  val referer = S.referer openOr "/"
  val client = TheClient.is openOr {S.error("client not provided");
S.redirectTo(referer)}
  val goBackFunc = ReturnToMe.is

  ... stuff here

  when done:

  goBackFunc.map(_.apply())
  S.redirectTo(referer)
}

So, your link to this page will contain a function that looks like:

{TheClient(Full(client)); ReturnToMe(Full({S.redirecTo(the from page, () =>
{re-associate your stateful snippet})}))}


On Wed, Aug 5, 2009 at 1:07 PM, Naftoli Gugenheim wrote:

>
> I don't have code available to post right now, but let me try to explain
> better.
> Basically you're editing a request, which is associated with a client. Now
> when your entering the request you may notice that the client's info is
> wrong. So I need a link to the client editing page, which is StatefulSnippet
> based. However, when that page loads it has to use an instance of the
> snippet that knows which client I want to edit.
>
> -
> David Pollak wrote:
>
> Please provide a complete (executable) code sample so I can understand the
> flow.
>
> On Wed, Aug 5, 2009 at 9:40 AM, Naftoli Gugenheim  >wrote:
>
> >
> > Hi. I have one screen, /requests/edit, that links to /clients/edit, in
> > order to edit a specific client. Both use StatefulSnippet. In the link I
> > specify a function that instantiates and registers an instance of that
> > StatefulSnippet. However the page does not use that instance but a new
> > instance instead. What am I doing wrong?
> > Thanks.
> >
> >
> > >
> >
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Git some: http://github.com/dpp
>
>
>
> >
>


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



--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Prepare StatefulSnippet in advance

2009-08-05 Thread David Pollak
Create a top-level RequestVar:

object TheClient extends RequestVar[Box[Client]](Empty)
object ReturnToMe extends RequestVar[Box[() => Unit]](Empty)

class ClientEditor extends StatefulSnippet {
  val referer = S.referer openOr "/"
  val client = TheClient.is openOr {S.error("client not provided");
S.redirectTo(referer)}
  val goBackFunc = ReturnToMe.is

  ... stuff here

  when done:

  goBackFunc.map(_.apply())
  S.redirectTo(referer)
}

So, your link to this page will contain a function that looks like:

{TheClient(Full(client)); ReturnToMe(Full({S.redirecTo(the from page, () =>
{re-associate your stateful snippet})}))}


On Wed, Aug 5, 2009 at 1:07 PM, Naftoli Gugenheim wrote:

>
> I don't have code available to post right now, but let me try to explain
> better.
> Basically you're editing a request, which is associated with a client. Now
> when your entering the request you may notice that the client's info is
> wrong. So I need a link to the client editing page, which is StatefulSnippet
> based. However, when that page loads it has to use an instance of the
> snippet that knows which client I want to edit.
>
> -
> David Pollak wrote:
>
> Please provide a complete (executable) code sample so I can understand the
> flow.
>
> On Wed, Aug 5, 2009 at 9:40 AM, Naftoli Gugenheim  >wrote:
>
> >
> > Hi. I have one screen, /requests/edit, that links to /clients/edit, in
> > order to edit a specific client. Both use StatefulSnippet. In the link I
> > specify a function that instantiates and registers an instance of that
> > StatefulSnippet. However the page does not use that instance but a new
> > instance instead. What am I doing wrong?
> > Thanks.
> >
> >
> > >
> >
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Git some: http://github.com/dpp
>
>
>
> >
>


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

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Prepare StatefulSnippet in advance

2009-08-05 Thread Naftoli Gugenheim

I don't have code available to post right now, but let me try to explain better.
Basically you're editing a request, which is associated with a client. Now when 
your entering the request you may notice that the client's info is wrong. So I 
need a link to the client editing page, which is StatefulSnippet based. 
However, when that page loads it has to use an instance of the snippet that 
knows which client I want to edit.

-
David Pollak wrote:

Please provide a complete (executable) code sample so I can understand the
flow.

On Wed, Aug 5, 2009 at 9:40 AM, Naftoli Gugenheim wrote:

>
> Hi. I have one screen, /requests/edit, that links to /clients/edit, in
> order to edit a specific client. Both use StatefulSnippet. In the link I
> specify a function that instantiates and registers an instance of that
> StatefulSnippet. However the page does not use that instance but a new
> instance instead. What am I doing wrong?
> Thanks.
>
>
> >
>


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



--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Loc.title impl redundancy?

2009-08-05 Thread David Pollak
On Wed, Aug 5, 2009 at 8:56 AM, Naftoli Gugenheim wrote:

>
> Why does title: NodeSeq try linkText if title(in:ParamType) calls
> linkText(in)?


Because it's possible to subclass the Loc and have your own implementation
of linkText.


> Is it possible that (forceParam or foundParam.is or defaultParams) will
> evaluate differently by that time?
>
> >
>


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

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Mega*ProtoUser extensibility - a suggestion.

2009-08-05 Thread David Pollak
There was a time when:

class Foo {
  def bar = "Hello"
}

object Moose {
  object foo1 extends Foo {
def baz = "Howdy"
  }

  val foo2 = new Foo {
def baz = "From another foo"
  }
}

println(Moose.foo1.baz)
println(Moose.foo2.baz)

Would not compile because the type of foo2 was Foo, not some subclass of
Foo.

I guess you could use a lazy val in place of an object and change its
implementation in the subclass (although it was rumored that a 2.8 feature
was the ability to change the implementation of an object in a subclass, but
I'm not sure it's going to make it in.)

But, at the end of the day, if you need that much customization of
ProtoUser, copy/paste the code and deal with your own implementation. :-)

On Wed, Aug 5, 2009 at 11:26 AM, E. Biggs  wrote:

>
> David,
>
> First apologies for accidently taking this thread off the lift group.
> It was entirely accidental.
>
> So my question with regards to the scala language that I can't seem to
> find an answer for online anywhere is what exactly is an object nested
> inside a class i.e. :
>
> class ObjectWrapper {
>  object obj extends AnyRef{var prop = "prop"}
> }
>
> versus a class with a final val that's set to an instance of an
> anonymous class i.e. :
>
> class AnonClassWrapper{
>  final val obj = new AnyRef{var prop="prop"}
> }
>
> I've tried to discover some sort of behavioral difference both in
> simple tests in the scala console, and couldn't find any. In both
> clases obj responds just as if it was a val and not a type. This
> analogy towards static classes in java breaks down because a static
> class in java is one that doesn't have a containing instance, and yet:
>
> scala> class ObjectWrapper{var outerProp = "prop"; object obj extends
> AnyRef{var prop=outerProp}}
> defined class ObjectWrapper
>
> lastly, in a desperate attempt to prove to myself that there is an
> actual difference I went against your rule and changed a RequestVar
> from an object extending RequestVar to a value set to an instance of
> an anonymous extention and my lift app ran without any changes in
> behavior???
>
> On Aug 4, 10:42 am, David Pollak 
> wrote:
> > In this case, if you change the type/behavior of the SessionVar and/or
> > RequestVar, you could mess up code that depends on these.
> >
> > You also must *always* make RequestVar and SessionVar as object rather
> than
> > val so that they can make the determination of their unique string ID.
> >
> > I view ProtoUser much like I view Rails' scaffolding... at some point the
> > code becomes too heavy to keep subclassing and it's easier to copy the
> > MegaProtoUser code into your own User class and go from there.
> >
> >
> >
> >
> >
> > On Tue, Aug 4, 2009 at 10:27 AM, E. Biggs  wrote:
> >
> > > I have extended Mega*ProtoUser to achieve cookie-based perpetual
> > > login..  and it was fairly easy to do except I ended up having to do
> > > something hackish simply because there are two private object members
> > > in the class that are core to the functionality I've extended.
> >
> > > Namely:
> >
> > > private object curUserId extends SessionVar[Box[String]](Empty)
> >
> > > private object curUser extends RequestVar[Box[ModelType]]
> > > (currentUserId.flatMap(id => getSingleton.find(id)))
> >
> > > I have no idea if this would be an acceptable change, but at least for
> > > one user of lift it would make much more sense that in the spirit of
> > > *ProtoUser's clear intent for extensibility that these members simply
> > > become:
> >
> > > protected val curUserId = new SessionVar[Box[String]](Empty){}
> >
> > > protected val curUser = new RequestVar[Box[ModelType]]
> > > (currentUserId.flatMap(id => getSingleton.find(id))){}
> >
> > > Unless I'm not properly understanding what object members actually
> > > are? I'm interpreting them as being final vals assigned to instances
> > > of anonymous classes (rough tests in the scala console seem to verify
> > > this)
> >
> > --
> > Lift, the simply functional web frameworkhttp://liftweb.net
> > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > Follow me:http://twitter.com/dpp
> > Git some:http://github.com/dpp
>
> >
>


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

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Asynchronous Javascript problem

2009-08-05 Thread David Pollak
On Wed, Aug 5, 2009 at 12:13 PM, Channing Walton wrote:

>
> actually that example doesn't work in Opera, but does in safari and
> firefox. To see the problem in safari I had to modify the script like
> this:
>
> var geocoder = new GClientGeocoder();
> geocoder.getLatLng("london",doit);
>
> function doit(point) {
>  var s = JSON.stringify(point);
>  alert(s)
> }
>
> This does work in Firefox though, but my full version doesn't.
> Hopefully these examples will help a little. I am beginning to think I
> should just pass simple objects to the server via JSON.


In order to debug the problem, I need something that is fully running (e.g.,
fork http://github.com/dpp/lift_1_1_sample/tree/master and implement
something that demonstrates the problem).

The mechanism we are working on is passing the objects to the server via
JSON.  JSON.stringify is the JSON serializer and an JavaScript object must
be serialized to send to the server.


>
> >
>


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

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Asynchronous Javascript problem

2009-08-05 Thread Channing Walton

actually that example doesn't work in Opera, but does in safari and
firefox. To see the problem in safari I had to modify the script like
this:

var geocoder = new GClientGeocoder();
geocoder.getLatLng("london",doit);

function doit(point) {
  var s = JSON.stringify(point);
  alert(s)
}

This does work in Firefox though, but my full version doesn't.
Hopefully these examples will help a little. I am beginning to think I
should just pass simple objects to the server via JSON.
--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Mega*ProtoUser extensibility - a suggestion.

2009-08-05 Thread E. Biggs

David,

First apologies for accidently taking this thread off the lift group.
It was entirely accidental.

So my question with regards to the scala language that I can't seem to
find an answer for online anywhere is what exactly is an object nested
inside a class i.e. :

class ObjectWrapper {
  object obj extends AnyRef{var prop = "prop"}
}

versus a class with a final val that's set to an instance of an
anonymous class i.e. :

class AnonClassWrapper{
  final val obj = new AnyRef{var prop="prop"}
}

I've tried to discover some sort of behavioral difference both in
simple tests in the scala console, and couldn't find any. In both
clases obj responds just as if it was a val and not a type. This
analogy towards static classes in java breaks down because a static
class in java is one that doesn't have a containing instance, and yet:

scala> class ObjectWrapper{var outerProp = "prop"; object obj extends
AnyRef{var prop=outerProp}}
defined class ObjectWrapper

lastly, in a desperate attempt to prove to myself that there is an
actual difference I went against your rule and changed a RequestVar
from an object extending RequestVar to a value set to an instance of
an anonymous extention and my lift app ran without any changes in
behavior???

On Aug 4, 10:42 am, David Pollak 
wrote:
> In this case, if you change the type/behavior of the SessionVar and/or
> RequestVar, you could mess up code that depends on these.
>
> You also must *always* make RequestVar and SessionVar as object rather than
> val so that they can make the determination of their unique string ID.
>
> I view ProtoUser much like I view Rails' scaffolding... at some point the
> code becomes too heavy to keep subclassing and it's easier to copy the
> MegaProtoUser code into your own User class and go from there.
>
>
>
>
>
> On Tue, Aug 4, 2009 at 10:27 AM, E. Biggs  wrote:
>
> > I have extended Mega*ProtoUser to achieve cookie-based perpetual
> > login..  and it was fairly easy to do except I ended up having to do
> > something hackish simply because there are two private object members
> > in the class that are core to the functionality I've extended.
>
> > Namely:
>
> > private object curUserId extends SessionVar[Box[String]](Empty)
>
> > private object curUser extends RequestVar[Box[ModelType]]
> > (currentUserId.flatMap(id => getSingleton.find(id)))
>
> > I have no idea if this would be an acceptable change, but at least for
> > one user of lift it would make much more sense that in the spirit of
> > *ProtoUser's clear intent for extensibility that these members simply
> > become:
>
> > protected val curUserId = new SessionVar[Box[String]](Empty){}
>
> > protected val curUser = new RequestVar[Box[ModelType]]
> > (currentUserId.flatMap(id => getSingleton.find(id))){}
>
> > Unless I'm not properly understanding what object members actually
> > are? I'm interpreting them as being final vals assigned to instances
> > of anonymous classes (rough tests in the scala console seem to verify
> > this)
>
> --
> Lift, the simply functional web frameworkhttp://liftweb.net
> Beginning Scalahttp://www.apress.com/book/view/1430219890
> Follow me:http://twitter.com/dpp
> Git some:http://github.com/dpp

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Title function

2009-08-05 Thread Naftoli Gugenheim

You mean the snippet should put its new/edit flag somewhere that the Title can 
read, like a top level object? Then it doesn't need to be an AnyVar because it 
can be set on every request, if Title is processed after the snippet in each 
request--and if not then I don't see how a RequestVar etc. would work.
Seems like it may be more work than the other way, though.
By the way I sent corrected message afterward--my question was not about 
LocParams but of the items of type ParamType. 

-
Derek Chen-Becker wrote:

If you're just looking for a way to programmatically set the title, getting
into LocParam might be a little bit of overkill. It's probably simpler to
set up your own SessionVars or RequestVars and access them from the Title
closure:

http://scala-tools.org/scaladocs/liftweb/1.0/net/liftweb/sitemap/Loc/Title.html

Derek

On Wed, Aug 5, 2009 at 9:45 AM, Naftoli Gugenheim wrote:

>
>
> -
> Naftoli Gugenheim wrote:
>
> So what I'm not clear on now is the input to Title. What is a LocParam, and
> how do you you use loc params? What is forceParam, defaultParams, param, and
> foundParam? And in any case how can Title know the value of the registered
> StatefulSnippet's newOrEdit state?
> Thanks!
>
> -
> David Pollak wrote:
>
> On Tue, Aug 4, 2009 at 12:47 PM, Naftoli Gugenheim  >wrote:
>
> > Maybe my setup is atypical then :)
> > My default.html is does not have a title tag; instead each view has its
> > own, relying on head merge.
> > I don't know if originally I had it in default using lift:Menu.title or
> > not, but the difficulty with that would be that some pages can be used to
> > edit or add a new item, and the title needs to reflect that.
>
>
> Because the Title() case class takes a function, you can have it do all
> forms of stuff including looking to the current user, whether you're
> editing, and "do the right thing".
>
>
> >
> > So either (1) I need a way that the value of Menu.title will depend on
> data
> > in various StatefulSnippets; or (2) make the title ambiguous (add/edit
> > neutral); or (3) leave the titles in the views and process them with a
> > function somehow; or (4) put a snippet in the title of every view to get
> the
> > user.
> >
> >
> >
> > -
> > David Pollak wrote:
> >
> > On Sun, Aug 2, 2009 at 4:35 PM, Naftoli Gugenheim  > >wrote:
> >
> > >
> > > How does the Title LocParam work?
> >
> >
> > The Title case class has a function that converts the current object
> > associated with the Loc into a String representing the title of the page
> > represented by the Loc.
> >
> >
> > >
> > > Is there a way to modify all titles to e.g. include the logged in
> user's
> > > name, without having to edit all the views?
> >
> >
> > The  tag is typically defined in the default template.  You could
> > include a snippet in the  tag that would contain the user's name.
>  I
> > would see this as separate from the title of the specific page referred
> to
> > by the Loc.Title.
> >
> >
> > >
> > >
> > > >
> > >
> >
> >
> > --
> > Lift, the simply functional web framework http://liftweb.net
> > Beginning Scala http://www.apress.com/book/view/1430219890
> > Follow me: http://twitter.com/dpp
> > Git some: http://github.com/dpp
> >
> > >
> >
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Git some: http://github.com/dpp
>
> >
>



--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: New features

2009-08-05 Thread Naftoli Gugenheim

I'll try.
By the way, as per my correction, you can implement list the regular way 
without ModelView, and just use ModelSnippet's load function in your edit link 
or button, passing it the User instance.

-
glenn wrote:


Naftoli,

I fixed my code per your comments and now I can edit and remove users
from a list, as long as I populate the list with
ModelView instances, as you said. As for the docs, this step was not
clear to me at all. I just assumed that the list was
just populated with User entities and the view in the ModelSnippet was
instantiated with the selected User on each request.

It sounds like your plate is pretty full, so I won't expect much, but
sometime soon, could you provide an example, or improved
docs, for using TableEditor and its related ItemsList trait.

Thanks for all.

Glenn...

On Aug 5, 9:18 am, Naftoli Gugenheim  wrote:
> Correction: ModelSnippet.load takes the actual Mapper instance, not the 
> ModelView wrapper.
>
> -
>
> Naftoli Gugenheim wrote:
>
> To answer your immediate question, the listing should not refer to the 
> snippet's view but new ModelView instances for each entity. Then editAction 
> is shorthand for the snippet's link method with a callback to call load on 
> the ModelView. To set the snippet's view's entity, either call load on the 
> snippet with the other ModelView, or call load on the other ModelView (or 
> just set its entity directly).
> As far as documentation, please tell me what scaladocs need what 
> clarification. Thanks.
>
> -
>
> glenn wrote:
>
> Naftoli,
>
> Functional programming systems are notoriously difficult to document.
> The only way to really know what's going on is to meticulously trace
> through the source. But that requires
> time-consuming trial and error coding. So, without clear examples
> demonstrating exactly what you have in mind, I and others in the same
> boat, could spend days and still not
> get it right.
>
> For example, I tried this:
>
> var theUser:User = null
> val view = new ModelView(theUser, this)
>
>  def list(ns: NodeSeq): NodeSeq =  User.currentUser.map({user =>
>         User.findAll.flatMap({u =>
>             bind("user", chooseTemplate("user", "entry", ns),
>                  "firstname" -> Text(u.firstName.is),
>                  "lastname" -> Text(u.lastName.is),
>                  "email" -> Text(u.email.is),
>                  "roles" -> u.roles.map(_.name.toString).mkString(",
> "),
>                  view.editAction,
>                  view.removeAction
>                  )
>           })
>                         }) openOr Text("You're not logged in")
>
> and, I get a null value exception when I try to remove a user in the
> list. Simply using
> val view = new ModelView(new User, this), doesn't work either,
> although I don't get an
> exception. Now, where should I be calling load in all of this?
>
> Glenn...
>
> On Aug 3, 6:22 pm, Naftoli Gugenheim  wrote:
>
> > Your snippet should extend ModelSnippet (which extends StatefulSnippet).
> > Then write:
> > val view = new ModelView(new User, this) {}
> > Calling load on another ModelView that references the snippet will load its 
> > entity into that view val. It has a number of methods of possible interest, 
> > like save which checks validity.
> > Also see Util.
> > Are you seeing the scaladocs?
>
> > -
>
> > glenn wrote:
>
> > Just to add to what I just wrote, I don't see how your ModelView can
> > be applied to
> > User, which already extends a class, MegaProtoUser.  Maybe I'm not
> > comprehending this correctly.
>
> > Glenn...
>
> > On Aug 3, 3:48 pm, glenn  wrote:
>
> > > Naftoli,
>
> > > Liked your OneToMany article, but not sure how the new
> > > ModelView and ModelSnippet code can be applied to ManyToMany.
> > > Can you provide a sample?
>
> > > Glenn...
>
> > > On Aug 2, 1:21 pm, Naftoli Gugenheim  wrote:
>
> > > > I put an article on the wiki about OneToMany 
> > > > --http://wiki.github.com/dpp/liftweb/how-to-work-with-one-to-many-relat...
> > > > .
>
> > > > On Sun, Aug 2, 2009 at 11:20 AM, Naftoli Gugenheim 
> > > > wrote:
>
> > > > > Glad to hear. Also see mapper.view.ItemsList (anyone have a better 
> > > > > name?),
> > > > > which is used byTableEditor. It's a similar idea without 
> > > > > relationships.
> > > > > Should MappedOne/ManyToMany be based on ItemsList?
> > > > > Also should I take Mapped out of those names? After all, they're not
> > > > > MappedFields and they don't correspond to a table column.
>
> > > > > -
> > > > > Magnus Alvestad wrote:
>
> > > > > This work that you've done in Mapper fits in very well with something
> > > > > I've been planning to do. In a Java project some time ago we
> > > > > implemented a 'change engine'. We were loading big pension agreements,
> > > > > manipulating them in a web interface and finally saving them back

[Lift] Re: Title function

2009-08-05 Thread Derek Chen-Becker
If you're just looking for a way to programmatically set the title, getting
into LocParam might be a little bit of overkill. It's probably simpler to
set up your own SessionVars or RequestVars and access them from the Title
closure:

http://scala-tools.org/scaladocs/liftweb/1.0/net/liftweb/sitemap/Loc/Title.html

Derek

On Wed, Aug 5, 2009 at 9:45 AM, Naftoli Gugenheim wrote:

>
>
> -
> Naftoli Gugenheim wrote:
>
> So what I'm not clear on now is the input to Title. What is a LocParam, and
> how do you you use loc params? What is forceParam, defaultParams, param, and
> foundParam? And in any case how can Title know the value of the registered
> StatefulSnippet's newOrEdit state?
> Thanks!
>
> -
> David Pollak wrote:
>
> On Tue, Aug 4, 2009 at 12:47 PM, Naftoli Gugenheim  >wrote:
>
> > Maybe my setup is atypical then :)
> > My default.html is does not have a title tag; instead each view has its
> > own, relying on head merge.
> > I don't know if originally I had it in default using lift:Menu.title or
> > not, but the difficulty with that would be that some pages can be used to
> > edit or add a new item, and the title needs to reflect that.
>
>
> Because the Title() case class takes a function, you can have it do all
> forms of stuff including looking to the current user, whether you're
> editing, and "do the right thing".
>
>
> >
> > So either (1) I need a way that the value of Menu.title will depend on
> data
> > in various StatefulSnippets; or (2) make the title ambiguous (add/edit
> > neutral); or (3) leave the titles in the views and process them with a
> > function somehow; or (4) put a snippet in the title of every view to get
> the
> > user.
> >
> >
> >
> > -
> > David Pollak wrote:
> >
> > On Sun, Aug 2, 2009 at 4:35 PM, Naftoli Gugenheim  > >wrote:
> >
> > >
> > > How does the Title LocParam work?
> >
> >
> > The Title case class has a function that converts the current object
> > associated with the Loc into a String representing the title of the page
> > represented by the Loc.
> >
> >
> > >
> > > Is there a way to modify all titles to e.g. include the logged in
> user's
> > > name, without having to edit all the views?
> >
> >
> > The  tag is typically defined in the default template.  You could
> > include a snippet in the  tag that would contain the user's name.
>  I
> > would see this as separate from the title of the specific page referred
> to
> > by the Loc.Title.
> >
> >
> > >
> > >
> > > >
> > >
> >
> >
> > --
> > Lift, the simply functional web framework http://liftweb.net
> > Beginning Scala http://www.apress.com/book/view/1430219890
> > Follow me: http://twitter.com/dpp
> > Git some: http://github.com/dpp
> >
> > >
> >
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Git some: http://github.com/dpp
>
> >
>

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: New features

2009-08-05 Thread glenn

Naftoli,

I fixed my code per your comments and now I can edit and remove users
from a list, as long as I populate the list with
ModelView instances, as you said. As for the docs, this step was not
clear to me at all. I just assumed that the list was
just populated with User entities and the view in the ModelSnippet was
instantiated with the selected User on each request.

It sounds like your plate is pretty full, so I won't expect much, but
sometime soon, could you provide an example, or improved
docs, for using TableEditor and its related ItemsList trait.

Thanks for all.

Glenn...

On Aug 5, 9:18 am, Naftoli Gugenheim  wrote:
> Correction: ModelSnippet.load takes the actual Mapper instance, not the 
> ModelView wrapper.
>
> -
>
> Naftoli Gugenheim wrote:
>
> To answer your immediate question, the listing should not refer to the 
> snippet's view but new ModelView instances for each entity. Then editAction 
> is shorthand for the snippet's link method with a callback to call load on 
> the ModelView. To set the snippet's view's entity, either call load on the 
> snippet with the other ModelView, or call load on the other ModelView (or 
> just set its entity directly).
> As far as documentation, please tell me what scaladocs need what 
> clarification. Thanks.
>
> -
>
> glenn wrote:
>
> Naftoli,
>
> Functional programming systems are notoriously difficult to document.
> The only way to really know what's going on is to meticulously trace
> through the source. But that requires
> time-consuming trial and error coding. So, without clear examples
> demonstrating exactly what you have in mind, I and others in the same
> boat, could spend days and still not
> get it right.
>
> For example, I tried this:
>
> var theUser:User = null
> val view = new ModelView(theUser, this)
>
>  def list(ns: NodeSeq): NodeSeq =  User.currentUser.map({user =>
>         User.findAll.flatMap({u =>
>             bind("user", chooseTemplate("user", "entry", ns),
>                  "firstname" -> Text(u.firstName.is),
>                  "lastname" -> Text(u.lastName.is),
>                  "email" -> Text(u.email.is),
>                  "roles" -> u.roles.map(_.name.toString).mkString(",
> "),
>                  view.editAction,
>                  view.removeAction
>                  )
>           })
>                         }) openOr Text("You're not logged in")
>
> and, I get a null value exception when I try to remove a user in the
> list. Simply using
> val view = new ModelView(new User, this), doesn't work either,
> although I don't get an
> exception. Now, where should I be calling load in all of this?
>
> Glenn...
>
> On Aug 3, 6:22 pm, Naftoli Gugenheim  wrote:
>
> > Your snippet should extend ModelSnippet (which extends StatefulSnippet).
> > Then write:
> > val view = new ModelView(new User, this) {}
> > Calling load on another ModelView that references the snippet will load its 
> > entity into that view val. It has a number of methods of possible interest, 
> > like save which checks validity.
> > Also see Util.
> > Are you seeing the scaladocs?
>
> > -
>
> > glenn wrote:
>
> > Just to add to what I just wrote, I don't see how your ModelView can
> > be applied to
> > User, which already extends a class, MegaProtoUser.  Maybe I'm not
> > comprehending this correctly.
>
> > Glenn...
>
> > On Aug 3, 3:48 pm, glenn  wrote:
>
> > > Naftoli,
>
> > > Liked your OneToMany article, but not sure how the new
> > > ModelView and ModelSnippet code can be applied to ManyToMany.
> > > Can you provide a sample?
>
> > > Glenn...
>
> > > On Aug 2, 1:21 pm, Naftoli Gugenheim  wrote:
>
> > > > I put an article on the wiki about OneToMany 
> > > > --http://wiki.github.com/dpp/liftweb/how-to-work-with-one-to-many-relat...
> > > > .
>
> > > > On Sun, Aug 2, 2009 at 11:20 AM, Naftoli Gugenheim 
> > > > wrote:
>
> > > > > Glad to hear. Also see mapper.view.ItemsList (anyone have a better 
> > > > > name?),
> > > > > which is used byTableEditor. It's a similar idea without 
> > > > > relationships.
> > > > > Should MappedOne/ManyToMany be based on ItemsList?
> > > > > Also should I take Mapped out of those names? After all, they're not
> > > > > MappedFields and they don't correspond to a table column.
>
> > > > > -
> > > > > Magnus Alvestad wrote:
>
> > > > > This work that you've done in Mapper fits in very well with something
> > > > > I've been planning to do. In a Java project some time ago we
> > > > > implemented a 'change engine'. We were loading big pension agreements,
> > > > > manipulating them in a web interface and finally saving them back to
> > > > > the database. While the user was working on the agreement, we
> > > > > generated a list of changes, containing enough information to replay
> > > > > or unroll the change. We could use this to implement undo and some
> > > > > semi-intelligent 

[Lift] Re: Prepare StatefulSnippet in advance

2009-08-05 Thread David Pollak
Please provide a complete (executable) code sample so I can understand the
flow.

On Wed, Aug 5, 2009 at 9:40 AM, Naftoli Gugenheim wrote:

>
> Hi. I have one screen, /requests/edit, that links to /clients/edit, in
> order to edit a specific client. Both use StatefulSnippet. In the link I
> specify a function that instantiates and registers an instance of that
> StatefulSnippet. However the page does not use that instance but a new
> instance instead. What am I doing wrong?
> Thanks.
>
>
> >
>


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

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Prepare StatefulSnippet in advance

2009-08-05 Thread Naftoli Gugenheim

Hi. I have one screen, /requests/edit, that links to /clients/edit, in order to 
edit a specific client. Both use StatefulSnippet. In the link I specify a 
function that instantiates and registers an instance of that StatefulSnippet. 
However the page does not use that instance but a new instance instead. What am 
I doing wrong?
Thanks.


--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: New features

2009-08-05 Thread Naftoli Gugenheim

Correction: ModelSnippet.load takes the actual Mapper instance, not the 
ModelView wrapper.

-
Naftoli Gugenheim wrote:

To answer your immediate question, the listing should not refer to the 
snippet's view but new ModelView instances for each entity. Then editAction is 
shorthand for the snippet's link method with a callback to call load on the 
ModelView. To set the snippet's view's entity, either call load on the snippet 
with the other ModelView, or call load on the other ModelView (or just set its 
entity directly).
As far as documentation, please tell me what scaladocs need what clarification. 
Thanks.



-
glenn wrote:


Naftoli,

Functional programming systems are notoriously difficult to document.
The only way to really know what's going on is to meticulously trace
through the source. But that requires
time-consuming trial and error coding. So, without clear examples
demonstrating exactly what you have in mind, I and others in the same
boat, could spend days and still not
get it right.

For example, I tried this:

var theUser:User = null
val view = new ModelView(theUser, this)

 def list(ns: NodeSeq): NodeSeq =  User.currentUser.map({user =>
User.findAll.flatMap({u =>
bind("user", chooseTemplate("user", "entry", ns),
 "firstname" -> Text(u.firstName.is),
 "lastname" -> Text(u.lastName.is),
 "email" -> Text(u.email.is),
 "roles" -> u.roles.map(_.name.toString).mkString(",
"),
 view.editAction,
 view.removeAction
 )
  })
}) openOr Text("You're not logged in")


and, I get a null value exception when I try to remove a user in the
list. Simply using
val view = new ModelView(new User, this), doesn't work either,
although I don't get an
exception. Now, where should I be calling load in all of this?

Glenn...


On Aug 3, 6:22 pm, Naftoli Gugenheim  wrote:
> Your snippet should extend ModelSnippet (which extends StatefulSnippet).
> Then write:
> val view = new ModelView(new User, this) {}
> Calling load on another ModelView that references the snippet will load its 
> entity into that view val. It has a number of methods of possible interest, 
> like save which checks validity.
> Also see Util.
> Are you seeing the scaladocs?
>
> -
>
> glenn wrote:
>
> Just to add to what I just wrote, I don't see how your ModelView can
> be applied to
> User, which already extends a class, MegaProtoUser.  Maybe I'm not
> comprehending this correctly.
>
> Glenn...
>
> On Aug 3, 3:48 pm, glenn  wrote:
>
> > Naftoli,
>
> > Liked your OneToMany article, but not sure how the new
> > ModelView and ModelSnippet code can be applied to ManyToMany.
> > Can you provide a sample?
>
> > Glenn...
>
> > On Aug 2, 1:21 pm, Naftoli Gugenheim  wrote:
>
> > > I put an article on the wiki about OneToMany 
> > > --http://wiki.github.com/dpp/liftweb/how-to-work-with-one-to-many-relat...
> > > .
>
> > > On Sun, Aug 2, 2009 at 11:20 AM, Naftoli Gugenheim 
> > > wrote:
>
> > > > Glad to hear. Also see mapper.view.ItemsList (anyone have a better 
> > > > name?),
> > > > which is used by TableEditor. It's a similar idea without relationships.
> > > > Should MappedOne/ManyToMany be based on ItemsList?
> > > > Also should I take Mapped out of those names? After all, they're not
> > > > MappedFields and they don't correspond to a table column.
>
> > > > -
> > > > Magnus Alvestad wrote:
>
> > > > This work that you've done in Mapper fits in very well with something
> > > > I've been planning to do. In a Java project some time ago we
> > > > implemented a 'change engine'. We were loading big pension agreements,
> > > > manipulating them in a web interface and finally saving them back to
> > > > the database. While the user was working on the agreement, we
> > > > generated a list of changes, containing enough information to replay
> > > > or unroll the change. We could use this to implement undo and some
> > > > semi-intelligent merging when two users were trying to commit  changes
> > > > to the same agreement. We also let the user review his changes before
> > > > saving, and we indicated changed fields visually. We were even
> > > > thinking of implementing some kind of macro or replay functionality,
> > > > but never got that far.
>
> > > > I've been trying to implement something similar as a lift component,
> > > > but with the old relationship handling it wasn't practical. With your
> > > > changes it should be. Thanks!
>
> > > > -Magnus
>
> > > > On Jul 27, 9:57 pm, Naftoli Gugenheim  wrote:
> > > > > I committed some code last night, which can help building mapper-based
> > > > view snippets, with G-d's help. It includes the following classes:
> > > > > (1-2) net.liftweb.mapper.OneToMany, ManyToMany: Gives a more
> > > > object-oriented app

[Lift] Loc.title impl redundancy?

2009-08-05 Thread Naftoli Gugenheim

Why does title: NodeSeq try linkText if title(in:ParamType) calls linkText(in)? 
Is it possible that (forceParam or foundParam.is or defaultParams) will 
evaluate differently by that time?

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Title function

2009-08-05 Thread Naftoli Gugenheim


-
Naftoli Gugenheim wrote:

So what I'm not clear on now is the input to Title. What is a LocParam, and how 
do you you use loc params? What is forceParam, defaultParams, param, and 
foundParam? And in any case how can Title know the value of the registered 
StatefulSnippet's newOrEdit state?
Thanks!

-
David Pollak wrote:

On Tue, Aug 4, 2009 at 12:47 PM, Naftoli Gugenheim wrote:

> Maybe my setup is atypical then :)
> My default.html is does not have a title tag; instead each view has its
> own, relying on head merge.
> I don't know if originally I had it in default using lift:Menu.title or
> not, but the difficulty with that would be that some pages can be used to
> edit or add a new item, and the title needs to reflect that.


Because the Title() case class takes a function, you can have it do all
forms of stuff including looking to the current user, whether you're
editing, and "do the right thing".


>
> So either (1) I need a way that the value of Menu.title will depend on data
> in various StatefulSnippets; or (2) make the title ambiguous (add/edit
> neutral); or (3) leave the titles in the views and process them with a
> function somehow; or (4) put a snippet in the title of every view to get the
> user.
>
>
>
> -
> David Pollak wrote:
>
> On Sun, Aug 2, 2009 at 4:35 PM, Naftoli Gugenheim  >wrote:
>
> >
> > How does the Title LocParam work?
>
>
> The Title case class has a function that converts the current object
> associated with the Loc into a String representing the title of the page
> represented by the Loc.
>
>
> >
> > Is there a way to modify all titles to e.g. include the logged in user's
> > name, without having to edit all the views?
>
>
> The  tag is typically defined in the default template.  You could
> include a snippet in the  tag that would contain the user's name.  I
> would see this as separate from the title of the specific page referred to
> by the Loc.Title.
>
>
> >
> >
> > >
> >
>
>
> --
> Lift, the simply functional web framework http://liftweb.net
> Beginning Scala http://www.apress.com/book/view/1430219890
> Follow me: http://twitter.com/dpp
> Git some: http://github.com/dpp
>
> >
>


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

--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Asynchronous Javascript problem

2009-08-05 Thread Channing Walton

ok, lots of jscript debugging and I'm pretty sure its this:

JSON.stringify(new GLatLng(0,0))

where GLatLng is a google map object.

the imports needed for this are

http://maps.google.com/maps?
file=api&v=2.x&key=your-key&sensor=false" type="text/
javascript">



there is a key=your-key argument in that first import. don't worry
about that, just make sure you test the page using localhost, not
127.0.0.1, just localhost. The key is not used for file:// and
localhost addresses.
--~--~-~--~~~---~--~~
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 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Using ExtJS with Lift?

2009-08-05 Thread Stefan Scott

Thanks Derek!

On Aug 5, 7:26 am, Derek Chen-Becker  wrote:
> OK, so on re-read I totally misunderstood the question :P. If you write your
> own maven project you could put the scripts under
> src/main/resources/toserve/extjs (per your Boot example setting up
> ResourceServer). No need to hack on the lift module itself.
>
> Derek
>
> On Wed, Aug 5, 2009 at 4:23 AM, Derek Chen-Becker 
> wrote:
>
> > Your guess is correct. The jquery-ui-min.js contains the datePicker. We
> > used to use datePicker.js but then we switched to the datePicker that's in
> > jquery UI.
>
> > As for your question about where to put the scripts, you don't want to put
> > them in src/main/resources/toserve unless you're writing a widget or some
> > other programmatic user of the scripts. If you'll just be using the scripts
> > directly in your templates you can just put them in the normal
> > src/main/webapp tree (I usually make a scripts subdir to segregate things).
> > Let me know if that doesn't work or if I'm misunderstanding the question.
>
> > Derek
>
> > On Tue, Aug 4, 2009 at 5:47 PM, Stefan Scott 
> > wrote:
>
> >> Thanks for this info, Marius.
>
> >> To get started with Lift I'm reading through the excellent book
> >> "Exploring Lift" you wrote with Eric and Tyler (version 27 July 2009),
> >> plus the source for the PocketChange app and liftweb, downloaded from
> >> GitHub.
>
> >> As I'm still finding my way through the various packages and file
> >> locations, I hope you can bear with me a bit while I think out loud
> >> here to make sure I understand where to put the .js files and the
> >> references for JavaScript resources which aren't integrated into
> >> lift.
>
> >> ***
> >> The only real question I have is way down towards the end of this
> >> message, at the end of point (a):
>
> >> "Where do I put the 'toserve' directory, and how do I make sure that
> >> Maven uses it?"
>
> >> Feel free to skip most of this lengthy message and just read point (a)
> >> which is the only real question I have. I'm still just getting used to
> >> Maven and how it pulls files from various locations either locally or
> >> online.
>
> >> ***
>
> >> (1) Searching in directory C:\www\work\PocketChange\ (I'm currently
> >> serving lift web apps just locally, running Jetty under Windows), I
> >> see several .js files for JQuery:
>
> >> date.js
> >> jquery.datePicker.js
> >> jquery.tablesorter.min.js
> >> jquery-ui.min.js
>
> >> in directory:
>
> >> C:\www\work\PocketChange\src\main\webapp\scripts\
>
> >> So it looks like I could put any needed .js files in that directory.
>
> >> Searching for the string ".js" *inside* all .html files in directory C:
> >> \www\work\PocketChange, I find the file:
>
> >> C:\www\work\PocketChange\src\main\webapp\index.html
>
> >> which contains the tag:
>
> >>  >> script>
>
> >> referencing the file:
>
> >> jquery-ui.min.js
>
> >> in directory C:\www\work\PocketChange\src\main\webapp\scripts\ above.
>
> >> So again it looks like I can put any needed .js files in that
> >> directory, and reference them in the app's .html file(s) as shown
> >> above.
>
> >> (One strange minor thing I noticed: if I search inside all .html files
> >> in directory C:\www\work\PocketChange\ for the string "datePicker.js",
> >> it only shows up in lines that have been commented out. So one minor
> >> curiosity I have is: how is the code for datePicker.js being used?
> >> There appears to be a definition of it in jquery-ui.min.js, as well as
> >> a more readable definition of it in datePicker.js as well. I
> >> understand that JavaScript files are "minified" to remove unnecessary
> >> characters - does jquery-ui.min.js include the "minified" version of
> >> datePicker? Is file datePicker.js never sent to the browser?)
>
> >> (2) The search for the string ".js" inside all .html files also turned
> >> up two occurences in file:
>
> >> C:\www\work\PocketChange\src\main\webapp\templates-hidden\default.html
>
> >> in the tags:
>
> >>