gpt4 book ai didi

java - 隐式 QueryStringBindable java.util.List[models.InputTimeSheetDataStore]

转载 作者:太空宇宙 更新时间:2023-11-04 13:53:17 24 4
gpt4 key购买 nike

您好,我正在尝试将 models.InputTimeSheetDataStore 类型的对象列表从 View 传递到 application.java,并且我得到No QueryString binder found for type java.util.List[models.InputTimeSheetDataStore]。尝试为此类型实现隐式 QueryStringBindable 错误

在 application.java 中,我正在传递要查看的对象列表

InputTimeSheetDataStore ITSDS= new InputTimeSheetDataStore();
ITSDS.ConsultantName=EmployeeFilter;
ITSDS.Client=ClientFilter;
ITSDS.Project=ProjectFilter;
ITSDS.Role=EmployeeRoleFilter;
ITSDS.Task=Task;
ITSDS.TimeSheetDate=TimeSheetDate;
ITSDS.Hours=TaskHours;
ITSDS.IsBilled=IsBilled;
ITSDS.Workplace=WorkPlace;
InputTimeSheetList.add(ITSDS);
return ok(TimeSheetInput.render(Consultant.PopulateConsultant(),Client.PopulateClient(),Project.PopulateProject(ClientFilter),
Consultant.PopulateConsultantRole(),Consultant.ConsultantRoleRate(EmployeeRoleFilter),InputTimeSheetList));

鉴于我正在将该对象传递回 application.java

@(EmployeeList:java.util.List[String],ClientList:java.util.List[String],
ProjectList:java.util.List[String],EmployeeRoleList: java.util.List[String],Rate:String,
CurrentPage:List[InputTimeSheetDataStore])

<form id="TimeSheetEntryForm" name="TimeSheetEntryForm" action="@{routes.Application.save("name","name","name","name","name","name","name","name","name",CurrentPage)}" method="GET">
<code.....>

这是我的类文件

InputTimeSheetDataStore.java

package models;


public class InputTimeSheetDataStore {

public String ConsultantName;
public String Client;
public String Project;
public String Role;
public String Task;
public String TimeSheetDate;
public String Hours;
public String IsBilled;
public String Workplace;

public String getConsultantName(){
return this.ConsultantName;
}
public String getClient(){
return this.Client;
}
public String getProject(){
return this.Project;
}
public String getRole(){
return this.Role;
}
public String getTask(){
return this.Task;
}
public String getTimeSheetDate(){
return this.TimeSheetDate;
}
public String getHours(){
return this.Hours;
}
public String getIsBilled(){
return this.IsBilled;
}
public String getWorkPlace(){
return this.Workplace;
}

}

我的路线是

GET     /Application/save            controllers.Application.save(EmployeeFilter:String,ClientFilter:String,ProjectFilter:String, EmployeeRoleFilter:String,Task:String,TaskHours:String,TimeSheetDate:String,IsBilled:String,WorkPlace:String,CurrentPage:java.util.List[models.InputTimeSheetDataStore])

有人可以帮助我使用 InputTimeSheetDataStore 类型的隐式查询绑定(bind)器

提前致谢

最佳答案

您好,这是 QueryStringbindable 的示例实现:

    public class InputTimeSheetDataStore implements QueryStringBindable<InputTimeSheetDataStore> {

public String consultantName, client, project;

@Override
public Optional bind(String key, Map data) {
if (data.containsKey("consultantName")) {
this. consultantName = data.get("consultantName").toString();
}

if (data.containsKey("client")) {
this.client = data.get("client").toString();
}

if (data.containsKey("project")) {
this.project = data.get("project").toString();
}

return Optional.of(this);
}

@Override
public String unbind(String key) {
return null;
}

@Override
public String javascriptUnbind() {
return null;
}
}

给您的额外提示,在编写编程语言时,请确保遵循代码约定。例如:Java语法中约定变量的第一个字符必须小写;

public String ConsultantName; // this is wrong
public String consultantName; //this is right

希望有帮助。

关于java - 隐式 QueryStringBindable java.util.List[models.InputTimeSheetDataStore],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30092217/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com