3
我創建了動作OnlyOwner與action composition獲取兩個用戶,並必須將它們返回給控制器。 下面的代碼解釋:從控制器傳遞參數到動作
控制器
@With(OnlyOwner.class) // Call to the action
public static Result profile(Long id) {
return ok(profile.render(user, userLogged));
}
行動
public class OnlyOwner extends Action.Simple{
@Override
public Promise<SimpleResult> call(Http.Context ctx) throws Throwable {
// Here I'm trying to get the Long id passed to che controller
Long id = (Long)ctx.args.get("id"); // but this retrieves a null
User user = User.findById(id);
User userLogged = // Here I get another user
// Now I want to return both the users to the controller
}
}
什麼是代碼這樣做呢?