[Lift] Re: Object typecast to Mapper

2009-04-27 Thread Amit Kumar Verma
Hi All, Thanks again, for support. Made many things more clear. Thanks Amit Kumar Verma On Apr 22, 1:35 am, David Pollak wrote: > Amit, > Class.forName(...) is called reflection in Scala/Java land.  It allows you > to get a class based on a String.  You can then create a new instance of the >

[Lift] Re: Object typecast to Mapper

2009-04-21 Thread David Pollak
Amit, Class.forName(...) is called reflection in Scala/Java land. It allows you to get a class based on a String. You can then create a new instance of the class with the newInstance() method. However, what you get is an instance of Object... and you have to case it into something else before us

[Lift] Re: Object typecast to Mapper

2009-04-20 Thread Sergey Andreev
Hi Amit, Try that one def bindObject[T <: AnyRef](className: Class[T]): Option[Object] = { val sClassName = className.getPackage.getName.concat(".Wrap".concat(className.getSimpleName)) try { Some(Class.forName(sClassName.replaceFirst("com.vtech", "com.vtech.appxtension")).newInsta

[Lift] Re: Object typecast to Mapper

2009-04-20 Thread Amit Kumar Verma
Hi All, This is a sample function for making an object from string at run time. Here we are not casting the object but creating one. I wanted the same thing for casting the object. public static Object bindObject(Class className) { Object objOutput = null; try { Strin

[Lift] Re: Object typecast to Mapper

2009-04-18 Thread Timothy Perrett
So your talking about reflection right? Take a look at scala Manifests (which aide getting round type erasure) - other than that scala supports all the normal reflection tooling that Java does. Tim On 18/04/2009 06:56, "Amit Kumar Verma" wrote: > "Scala is a static language, so the class for

[Lift] Re: Object typecast to Mapper

2009-04-18 Thread David Pollak
Amit, There is no way that I know of in Java to construct a string at runtime and use that string for casting. If you can show me an example of what you mean in Java I'll show you the equivilent Scala code. In terms of the roadmap, you started a thread on that. If you have follow-up questions,

[Lift] Re: Object typecast to Mapper

2009-04-18 Thread Amit Kumar Verma
Hi David, Sorry I used dynamic binding which was not correct. But in the previous thread you said : "Scala is a static language, so the class for casting must be known at compile time. It's not possible to construct a String at runtime and cast an object into a class represented by that String.

[Lift] Re: Object typecast to Mapper

2009-04-17 Thread David Pollak
On Fri, Apr 17, 2009 at 2:00 AM, Amit Kumar Verma wrote: > > Hi David, > > thanks, this is working fine. Problem is resolved. > > But dynamic binding is feature of java then why Scala don't support > this. I'm sorry, I don't understand what dynamic binding is. Scala supports casting just like J

[Lift] Re: Object typecast to Mapper

2009-04-17 Thread Amit Kumar Verma
Hi David, thanks, this is working fine. Problem is resolved. But dynamic binding is feature of java then why Scala don't support this. This is an important feature. Thanks again Amit Kumar Verma On Apr 13, 10:10 pm, David Pollak wrote: > I think it's best to use the built-in JSON creation cod

[Lift] Re: Object typecast to Mapper

2009-04-13 Thread David Pollak
I think it's best to use the built-in JSON creation code and keep the code as JsCmd as long as possible. Here's a snippet that will place the JSON for all the Users in the page. I'm including the whole project as well: class HelloWorld { def json: NodeSeq = Script(jsonForAll(User)) private d

[Lift] Re: Object typecast to Mapper

2009-04-13 Thread Amit Kumar Verma
Hi David, Thanks for ur replies, I just want to make a generic function which will take an object of mapper and returns the json string of the same. I have written only two function 1. This will be called by ajax call : def getJSONString(xhtml: Group):NodeSeq = { getJSONStringGeneric

[Lift] Re: Object typecast to Mapper

2009-04-10 Thread David Pollak
I think the .asJs method on all Mapper instances should give you the object in JavaScript representation. If you can post an entire file, I can work on helping you if the above doesn't work. On Thu, Apr 9, 2009 at 6:53 AM, Amit Kumar Verma wrote: > > copied the the same code but getting this erro

[Lift] Re: Object typecast to Mapper

2009-04-09 Thread Amit Kumar Verma
copied the the same code but getting this error type arguments [_] do not conform to trait MetaMapper's type parameter bounds [A <: net.liftweb.mapper.Mapper[A]] TravelMerchantTest/src/main/ scala/com/vtech/travelmerchant/snippet default.scala line 142 1239284830763 85593 Actually I am

[Lift] Re: Object typecast to Mapper

2009-04-09 Thread David Pollak
Howdy, Scala is a static language, so the class for casting must be known at compile time. It's not possible to construct a String at runtime and cast an object into a class represented by that String. However, casting to a known class is easy in Scala... and it's done primarily using pattern mat