2

I have a Java class like:

public class User {
   public String name;
   public String email;
}

Instead of creating another case class in Scala or using tuple, can I do something like

Form<User> form = Form.form(User.class)

The above code is possible in Play Java but not for Scala

3
  • Just an idea, but should work: What happens if you just import the Java form class and use it (i.e. use play.data.Form instead of the default one for Scala, play.api.data.Form)? You should be able to use that one from Scala exactly like from Java. Well, almost exactly, more like form:Form[User] = Form.form(User.class) Commented Aug 5, 2013 at 18:52
  • @Carsten I tried but Scala didn't allow me to use .class Commented Aug 5, 2013 at 19:18
  • stackoverflow.com/questions/1135248/… Commented Aug 5, 2013 at 19:50

1 Answer 1

2

.class isn't a keyword in Scala. Try classOf[User].

i.e.

val form = Form.form(classOf[User])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.