Migrate CRUD Plugin from Play 1.2.4 to 2.5.x : views compilation errors

46 Views Asked by At

i'm new on Playframework and i need to migrate the CRUD Plugin from Play-1.2.4 to a module on Play-2.5.x. I'm facing some strange problems with the views. For example the form.scala.html component have the following errors :

  • app\views\tags\crud\form.scala.html:28: not found: type fieldName
  • app\views\tags\crud\form.scala.html:28: variable fieldsHandler of type Array[String] does not take type parameters.
  • app\views\tags\crud\form.scala.html:31: not found: value field

Here is a piece of code of the form file :

@(fields: List[String], obj: Object, typ: controllers.CRUD.ObjectType)(body: Html)
@import scala.Predef;  var currentObject: Object = null; var currentType: controllers.CRUD.ObjectType = null; var fieldsHandler = new Array[String](10);

@for(fieldName <- fields) {
        var am : String = "";
        var field = @currentType.getField(fieldName);
        @if(field == null){
                throw new play.exceptions.TagInternalException("Field not found -> " + @fieldName)
            }
            @if(field.typ == "text") {
                @tags.crud.textField(fieldName, currentObject[fieldName])
            }
            @if(field.typ == "password") {
                @tags.crud.passwordField(fieldName, currentObject[fieldName])
            }
            @if(field.typ == "binary"){
                @tags.crud.fileField(fieldName, currentObject[fieldName], currentObject.id )
            }
    }

--> 80% of the compile errors are related to variable recognition !

A piece from build.sbt file:

scalaVersion := "2.11.7"
lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean, SbtTwirl)
fork in run := true

Any idea ? Your help will be appreciated. Thanks.

1

There are 1 best solutions below

0
G.Haithem On

I understood that the principle of the crud plugin is in contradiction with the new logic of compiling scala templates. So I started on a new generic implementation of crud. Thank you