dimanche 30 octobre 2016

How Can i paginate a list of object of my models (Play Framework)?

I'm New in this framework! I want to generate a paginator of my models to show my lits in the templates.

I'm Using Play-java, Ebean, scala.html templates.

Thanks!

I have this!

Model:

public static Finder<String,User> find = new Finder(
    String.class, User.class
);


public static  List<User> all(){
    return find.all();
}

Controller:

public class UserController extends Controller {

   public Result index() {
      return ok(list_users.render(User.all()));
   }
}

View (list_user.scala.html)

      <table>
             <thead>
                  <tr>
                    <th>Email</th>
                    <th>Name</th>
                    <th>Last Name</th>  
                 </tr>
             </thead>           
              <tbody>                
                @for(user<- users){               
                   <tr>
                       <td>@user.getEmail()</td>
                       <td>@user.getName()</td>
                       <td>@user.getLastName()</td>
                  </tr>       
               }
            </tbody>
    </table>         




Aucun commentaire:

Enregistrer un commentaire