0

i pass a lot of time trying to solve very simple problem render à string or(List) from controller to view using playframework java and Twirl, my code here


in my controller

  public Result list(){
            //List<String>  todo = Arrays.asList("sup1","sup2","sup3");
            String nana = "coco";
            return ok(index.render(nana));
        }

in my view

@(message: String)
@(nana:String)

@main("Welcome to Play") {

    @play20.welcome(message, style = "Java")
    <h1>@nana</h1>


}

so there are the some configuration for Twirl or automatically ? anyone help me to render data to view and thanks

A.khalifa
  • 1,974
  • 3
  • 20
  • 35

1 Answers1

1

What is the error you're seeing? What are the full blocks of code, with all imports?

The syntax seems to be all wrong:

  • Your template should only have one parameter declaration, which is the @(...) line at the top. If you want to pass in two values, you should write @(message: String, nana: String) at the top of your template. And then you need to pass values for both in when you call index.render(message, nana).
  • I'm not sure what @main refers to, since imports aren't listed, but you should try getting it to work first without that block. Render a plain string, then add in some variables, then maybe try for a fancy callback like @main.
acjay
  • 28,690
  • 4
  • 51
  • 93