编译错误:类列表中的方法渲染无法应用于给定类型; [英] Compilation error: method render in class list cannot be applied to given types;

查看:93
本文介绍了编译错误:类列表中的方法渲染无法应用于给定类型;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我仍在学习Play!Framework,作为一堂课,我决定在应用程序中包含一项新功能(在Samples中可用,称为计算机数据库").

I'm still learning Play!Framework and, as a lesson, I decided to include a new feature in a application (available in Samples, called "Computer Database").

这个程序非常简单.它具有计算机模型,并且与公司模型具有@ManyToOne关系.好吧,基本上我决定复制计算机模型,并制作了一个雇员模型,基本上是相同的.我复制了计算机模型,控制器和路由,但尝试编译失败,如下所示:

Well this app is very simple. It has a Computer model and it has a @ManyToOne relationship with a Company model. Well, basically I decided to copy Computer model and I made a Employee model, which is basically the same. I copied Computer Model, Controller and Routes and I tried to compile unsuccessfully, as you can see below:

public static Result list(int page, String sortBy, String order, String filter) {
    return ok(
        list.render( //-- LINE IN RED!
            Employee.page(page, 10, sortBy, order, filter),
            sortBy, order, filter
        )
    );
}

实际上,我之所以尝试编译它是因为我在寻找更多技巧,因为在Eclipse中还有其他问题,只有在我的新Controller(称为"Employees")中才有.上面的代码标记为:

Actually, I tried to compile it because I was looking for more tips, as I have other issues in my Eclipse, only in my new Controller, called "Employees". The code above is marked with:

Multiple markers at this line: Occurrence of 'render'; The method render(Page<Computer>, String, String, String) in the type list is not applicable for the arguments (Page<Employee>, String, String, String)

而且只有在此控制器中,我才有静态方法结果更新/创建/保存/删除并带有消息指向:

And only in this controller I have static methods Result update/create/save/delete pointed with a message:

The method render(Form < Computer >) in the type createForm is not applicable for the arguments (Form < Employee >)

重点是:我不打算将此方法与Employee obj参数一起使用.每个方法都包含:Form< Employee > employeeForm = form(Employee.class)...

The point is: I'm not trying to use this method with Employee obj arguments. Every single method contains: Form< Employee > employeeForm = form(Employee.class)...

我的IDE表示此方法渲染不适用于Employee Page的参数,仅适用于Computer Page的参数,这对我来说听起来很奇怪,因为正如我所说,这是一个通用类,一个播放框架本机类,和Employee和Computer是我创建的模型.

My IDE is saying this method render is not applicable for the Employee Page's arguments, only for Computer Page's, which sounds totally weird for me, because, as I said, it is a generic class, a play-framework native class, and Employee and Computer are models created by me.

-

  • Employee.page的签名:

  • Employee.page's signature:

public static Page< Employee > page(int page, int pageSize, String sortBy, String order, String filter)

-

我搜索了一个依赖项/库不一致,但是我个人可以找到它.我已经尝试过重新启动Eclipse,我的服务器,在控制台中播放干净"/更新"/etc ...我还能验证什么?

I searched a dependency/library inconsistency, but personally I could find it. I've already tried to restart Eclipse, my server, "play clean"/"update"/etc in the console... What else could I verify?

推荐答案

我们解决了我的问题.我们只需将诸如list.render之类的代码替换为先前已准备好的称为listEmployees.render的代码,然后对public static Result savepublic static Result create做同样的事情,在这种情况下,还要对其相应的createEmployeeForm做同样的事情.但是我们没有使用最初为此目的而开发的雇员视图,因为我们出色的Eclipse IDE指出了问题.

We solved my issue. We simply replace the code like list.render for a previously ready code called listEmployees.render and then we did the same for public static Result save and public static Result create, and in this case, for its corresponding createEmployeeForm, which was also previously done. But we were not using the Employees' views originally developed for this, because our great Eclipse IDE was pointing issues.

我们只是忽略了这个Eclipse问题,所以,它运行了!然后我们刷新了项目,现在是正确的.感谢大家的关注!

We simply ignored this Eclipse issue and, voilà, it runs! Then we refreshed the project and now it's right. Thanks for all attention!

这篇关于编译错误:类列表中的方法渲染无法应用于给定类型;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆