import play.*;
import play.mvc.*;
import play.data.*;
import play.data.Form.*;
import views.html.*;
import models.*;
import java.util.ArrayList;
import java.util.List;
public class Application extends Controller {
public Result index()
{
List members = Member.findAll();
return ok(index.render(members, Staff.getLoggedIn(session().get("staff_id")));
}
@Security.Authenticated(Secured.class)
public Result addMember()
{
Form addMemberForm = Form.form(Member.class);
return ok(addMember.render(addMemberForm,Staff.getLoggedIn(session().get("staff_id"))));
}
@Security.Authenticated(Secured.class)
public Result addMemberSubmit()
{
Form newMemberForm = Form.form(Member.class).bindFromRequest();
if(newMemberForm.hasErrors()){
return badRequest(addMember.render(newMemberForm, Staff.getLoggedIn(session().get("staff_id"))));
}
newMemberForm.get().save();
flash("success","Member" + newMemberForm.get().name +"has been created");
return redirect("/");
}
@Security.Authenticated(Secured.class)
public Result deleteMember(Long id)
{
Member.find.ref(id).delete();
flash("success", "Member has been deleted");
return redirect("/");
}
@Security.Authenticated(Secured.class)
public Result updateMember(Long id)
{
Form memberForm = Form.form(Member.class).fill(Member.find.byId(id));
return ok(updateMember.render(id, memberForm,Staff.getLoggedIn(session().get("staff_id"))));
}
@Security.Authenticated(Secured.class)
public Result updateMemberSubmit(Long id)
{
Form updateMemberForm = Form.form(Member.class).bindFromRequest();
if(updateMemberForm.hasErrors())
{
return badRequest(updateMember.render(id, updateMemberForm, Staff.getLoggedIn(session().get("staff_id"))));
}
Member m = updateMemberForm.get();
m.id = id;
m.update();
flash("Success", "Member "+updateMemberForm.get().name + " has been updated");
return redirect("/");
}
public Result login(){
return ok(login.render(Form.form(Login.class),Staff.getLoggedIn(session().get("staff_id"))));
}
public Result logout(){
session().clear();
flash("Success", "You've been logged out");
return redirect(routes.Application.login());
}
public Result authenticate(){
Form loginForm = Form.form(Login.class).bindFromRequest();
if(loginForm.hasErrors()){
return badRequest(login.render(loginForm,Staff.getLoggedIn(session().get("staff_id"))));
}
else{
session().clear();
session("email", loginForm.get().username);
return redirect(routes.Application.index());
}
}
}
这是我得到的错误,
`}' expected but eof found.
答案 0 :(得分:0)
我应该在下面的方法中使用了四个右括号:
public Result index()
{
List members = Member.findAll();
return ok(index.render(members, Staff.getLoggedIn(session().get("staff_id")));
}
我在)
ok(index.render(members, Staff.getLoggedIn(session().get("staff_id")))