[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 feeder.of.the.be...@gmail.com 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

[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

[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,

[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-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 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 cdac.a...@gmail.com wrote: Scala is a static language,

[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 feeder.of.the.be...@gmail.com wrote: I think it's best to use

[Lift] Re: Object typecast to Mapper

2009-04-17 Thread David Pollak
On Fri, Apr 17, 2009 at 2:00 AM, Amit Kumar Verma cdac.a...@gmail.comwrote: 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

[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 = {

[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

[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 cdac.a...@gmail.comwrote: copied the the same code but

[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