Even if the class was abstract, you could do:
val firstName = new MappedString(this, 32) {}

So, making the class abstract doesn't really help.

On Sun, Aug 9, 2009 at 12:40 PM, Jo <[email protected]> wrote:

>
> Hi,
>
>
> During my journey through the lift source code & examples I was
> wondering the following:
>
> you have  a simple mapped class User
>
> class Person extends LongKeyedMapper[Person] with IdPK {
>  def getSingleton = Person
>
>  object firstName extends MappedString(this, 100)
>  object lastName  extends MappedString(this, 100)
>
>
> I was wondering why firstName and lastName was an object. I also tried
> changing it to a val (just wondering what the result would be)
> so:
>
>  val firstName = new MappedString(this,100)
>
> This compiled without a problem, however at runtime, this would throw
> an exception.
>
> Exception occured while processing /database
>
> Message: java.lang.NullPointerException
>        net.liftweb.mapper.MappedField$class.dbColumnName(MappedField.scala:
> 516)
>        net.liftweb.mapper.MappedString.dbColumnName(MappedString.scala:38)
>        net.liftweb.mapper.MetaMapper$$anonfun$_addOrdering$1.apply
> (MetaMapper.scala:455)
>        net.liftweb.mapper.MetaMapper$$anonfun$_addOrdering$1.apply
> (MetaMapper.scala:454)
>        scala.List.flatMap(List.scala:1132)
>        net.liftweb.mapper.MetaMapper$class._addOrdering(MetaMapper.scala:
> 454)
>        net.liftweb.mapper.MetaMapper$class.addEndStuffs(MetaMapper.scala:
> 465)
>        net.liftweb.example.model.Person$.addEndStuffs(Person.scala:22)
>
>
> I have 2 questions:
>
> 1. why did the val firstName not work?


Because the way that reflection works in the Mapper class, we only look for
objects, not vals.


>
> 2. if this is prohibited, why is the MappedString class not abstract
> or a trait?


See above... and it can't be a trait because traits don't take constructor
parameters.

>
>
>
> Best regards,
>
>
> Jo
>
>
> >
>


-- 
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to