[Lift] Re: Two items on Record

2008-11-26 Thread David Pollak
On Wed, Nov 26, 2008 at 7:34 AM, Derek Chen-Becker [EMAIL PROTECTED]wrote:

 I'm in the process of playing with the Record code so I have some examples
 for the book. I've run into two small issues:


1. I'm writing a custom Field type (DecimalField) and it seems like the
valueCouldNotBeSet var should be set if I can't parse the decimal string
that a user hands me in setFromString. That var, however, is marked
private[record], so I can't actually access it. Could you provide an
accessor or make that var protected so that I can set it?
2. I'm getting a really weird type error if I try to override the
fieldOrder def on MetaRecord:


Try this:

object EntryMeta extends Entry with MetaRecord[Entry] {
  override def fieldOrder = List(date, description)
}



1.

 [WARNING]
 /home/software/liftbook-demos/demo-record/src/main/scala/com/theliftbook/model/Entry.scala:50:
 error: type mismatch;
 [WARNING]  found   :
 List[net.liftweb.record.Field[_10,com.theliftbook.model.Entry] forSome {
 type _10 : String with java.util.Calendar : java.lang.Comparable[_1]
 forSome { type _1 : java.lang.String with java.util.Calendar :
 java.io.Serializable } with java.io.Serializable }{def defaultValue:
 java.lang.Comparable[_12] forSome { type _12 : java.lang.String with
 java.util.Calendar : java.io.Serializable } with java.io.Serializable}]
 [WARNING]  required:
 List[net.liftweb.record.Field[_$3,com.theliftbook.model.Entry] forSome {
 type _$3 }]
 [WARNING]   override def fieldOrder = date :: description :: Nil

 Here's my code:

 class Entry extends Record[Entry] {
   def meta = EntryMeta

   object date extends DateTimeField(this)

   object description extends StringField(this, 100)
 }

 object EntryMeta extends Entry with MetaRecord[Entry] {
   override def fieldOrder = date :: description :: Nil
 }

 Am I making a dumb mistake here, or is there some other weirdness going on?

 Thanks,

 Derek

 



-- 
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---



[Lift] Re: Two items on Record

2008-11-26 Thread Marius



On Nov 26, 5:34 pm, Derek Chen-Becker [EMAIL PROTECTED] wrote:
 I'm in the process of playing with the Record code so I have some examples
 for the book. I've run into two small issues:

    1. I'm writing a custom Field type (DecimalField) and it seems like the
    valueCouldNotBeSet var should be set if I can't parse the decimal string
    that a user hands me in setFromString. That var, however, is marked
    private[record], so I can't actually access it. Could you provide an
    accessor or make that var protected so that I can set it?

valueCouldNoBeSet is used in the validation. I mean in order to
validate a field that field needs to have first a value of that type.
Since we can not always convert from a String to a Number we have this
cases where we can not set the value. Validation will generate an
error messag rturned by Field.errorMessage (probably needs renaming).

I'm aware that you may already know that, just wanted to express this
again.

The bottom line, you are right :) ... I'll provide access to this.



    2. I'm getting a really weird type error if I try to override the
    fieldOrder def on MetaRecord:

 [WARNING]
 /home/software/liftbook-demos/demo-record/src/main/scala/com/theliftbook/model/Entry.scala:50:
 error: type mismatch;
 [WARNING]  found   :
 List[net.liftweb.record.Field[_10,com.theliftbook.model.Entry] forSome {
 type _10 : String with java.util.Calendar : java.lang.Comparable[_1]
 forSome { type _1 : java.lang.String with java.util.Calendar :
 java.io.Serializable } with java.io.Serializable }{def defaultValue:
 java.lang.Comparable[_12] forSome { type _12 : java.lang.String with
 java.util.Calendar : java.io.Serializable } with java.io.Serializable}]
 [WARNING]  required:
 List[net.liftweb.record.Field[_$3,com.theliftbook.model.Entry] forSome {
 type _$3 }]
 [WARNING]   override def fieldOrder = date :: description :: Nil

 Here's my code:

 class Entry extends Record[Entry] {
   def meta = EntryMeta

   object date extends DateTimeField(this)

   object description extends StringField(this, 100)

 }

 object EntryMeta extends Entry with MetaRecord[Entry] {
   override def fieldOrder = date :: description :: Nil

 }

 Am I making a dumb mistake here, or is there some other weirdness going on?

 Thanks,

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



[Lift] Re: Two items on Record

2008-11-26 Thread Marius

please do a git pull

On Nov 26, 7:56 pm, Marius [EMAIL PROTECTED] wrote:
 On Nov 26, 5:34 pm, Derek Chen-Becker [EMAIL PROTECTED] wrote:

  I'm in the process of playing with the Record code so I have some examples
  for the book. I've run into two small issues:

     1. I'm writing a custom Field type (DecimalField) and it seems like the
     valueCouldNotBeSet var should be set if I can't parse the decimal string
     that a user hands me in setFromString. That var, however, is marked
     private[record], so I can't actually access it. Could you provide an
     accessor or make that var protected so that I can set it?

 valueCouldNoBeSet is used in the validation. I mean in order to
 validate a field that field needs to have first a value of that type.
 Since we can not always convert from a String to a Number we have this
 cases where we can not set the value. Validation will generate an
 error messag rturned by Field.errorMessage (probably needs renaming).

 I'm aware that you may already know that, just wanted to express this
 again.

 The bottom line, you are right :) ... I'll provide access to this.

     2. I'm getting a really weird type error if I try to override the
     fieldOrder def on MetaRecord:

  [WARNING]
  /home/software/liftbook-demos/demo-record/src/main/scala/com/theliftbook/model/Entry.scala:50:
  error: type mismatch;
  [WARNING]  found   :
  List[net.liftweb.record.Field[_10,com.theliftbook.model.Entry] forSome {
  type _10 : String with java.util.Calendar : java.lang.Comparable[_1]
  forSome { type _1 : java.lang.String with java.util.Calendar :
  java.io.Serializable } with java.io.Serializable }{def defaultValue:
  java.lang.Comparable[_12] forSome { type _12 : java.lang.String with
  java.util.Calendar : java.io.Serializable } with java.io.Serializable}]
  [WARNING]  required:
  List[net.liftweb.record.Field[_$3,com.theliftbook.model.Entry] forSome {
  type _$3 }]
  [WARNING]   override def fieldOrder = date :: description :: Nil

  Here's my code:

  class Entry extends Record[Entry] {
    def meta = EntryMeta

    object date extends DateTimeField(this)

    object description extends StringField(this, 100)

  }

  object EntryMeta extends Entry with MetaRecord[Entry] {
    override def fieldOrder = date :: description :: Nil

  }

  Am I making a dumb mistake here, or is there some other weirdness going on?

  Thanks,

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



[Lift] Re: Two items on Record

2008-11-26 Thread Derek Chen-Becker
Still getting the type error using an explicit List(...):

[WARNING]
/home/software/liftbook-demos/demo-record/src/main/scala/com/theliftbook/model/Entry.scala:50:
error: type mismatch;
[WARNING]  found   :
List[net.liftweb.record.Field[_10,com.theliftbook.model.Entry] forSome {
type _10 : String with java.util.Calendar : java.lang.Comparable[_1]
forSome { type _1 : java.lang.String with java.util.Calendar :
java.io.Serializable } with java.io.Serializable }{def defaultValue:
java.lang.Comparable[_12] forSome { type _12 : java.lang.String with
java.util.Calendar : java.io.Serializable } with java.io.Serializable}]
[WARNING]  required:
List[net.liftweb.record.Field[_$3,com.theliftbook.model.Entry] forSome {
type _$3 }]
[WARNING]   override def fieldOrder = List(date, description)

Marius, I checked the commit and that looks reasonable. I'm using the
snapshot repo right now so I'll modify my code to call
Field.couldNotSetValue and test in the morning. Thanks!

Derek

On Wed, Nov 26, 2008 at 10:35 AM, David Pollak 
[EMAIL PROTECTED] wrote:



 On Wed, Nov 26, 2008 at 7:34 AM, Derek Chen-Becker [EMAIL PROTECTED]wrote:

 I'm in the process of playing with the Record code so I have some examples
 for the book. I've run into two small issues:


1. I'm writing a custom Field type (DecimalField) and it seems like
the valueCouldNotBeSet var should be set if I can't parse the decimal 
 string
that a user hands me in setFromString. That var, however, is marked
private[record], so I can't actually access it. Could you provide an
accessor or make that var protected so that I can set it?
2. I'm getting a really weird type error if I try to override the
fieldOrder def on MetaRecord:


 Try this:

 object EntryMeta extends Entry with MetaRecord[Entry] {
   override def fieldOrder = List(date, description)
 }



1.

 [WARNING]
 /home/software/liftbook-demos/demo-record/src/main/scala/com/theliftbook/model/Entry.scala:50:
 error: type mismatch;
 [WARNING]  found   :
 List[net.liftweb.record.Field[_10,com.theliftbook.model.Entry] forSome {
 type _10 : String with java.util.Calendar : java.lang.Comparable[_1]
 forSome { type _1 : java.lang.String with java.util.Calendar :
 java.io.Serializable } with java.io.Serializable }{def defaultValue:
 java.lang.Comparable[_12] forSome { type _12 : java.lang.String with
 java.util.Calendar : java.io.Serializable } with java.io.Serializable}]
 [WARNING]  required:
 List[net.liftweb.record.Field[_$3,com.theliftbook.model.Entry] forSome {
 type _$3 }]
 [WARNING]   override def fieldOrder = date :: description :: Nil

 Here's my code:

 class Entry extends Record[Entry] {
   def meta = EntryMeta

   object date extends DateTimeField(this)

   object description extends StringField(this, 100)
 }

 object EntryMeta extends Entry with MetaRecord[Entry] {
   override def fieldOrder = date :: description :: Nil
 }

 Am I making a dumb mistake here, or is there some other weirdness going
 on?

 Thanks,

 Derek





 --
 Lift, the simply functional web framework http://liftweb.net
 Collaborative Task Management http://much4.us
 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~--~~~~--~~--~--~---