Here is my view page and here not get the id..
@(userprofiles: List[UserProfile], myFriend: models.MyFriend, userprofile: models.UserProfile)
@helper.form(action = routes.Application.listMyFriend) {
Value id is not a member of List[models.UserProfile]
Here is where the error occurred:
@for(userprofile <- userprofiles.id) {
@if(userprofile.id == userprofiles) {
} else {
<img src="@routes.Assets.at("images/img2.png")" width="200" height="200" />
<br><h5>@userprofile.name</h5>
<h6>@userprofile.gender</h6>
<h6>@userprofile.date_of_birth</h6>
<div class="actions">
<input type="submit" class="btn primary" value="+1 Add As Friend" title="Send Friend Request"></div>
<br/>
}
}
}
This is method in application
def listMyFriend = Action { implicit request =>
if (request.session.get("myFriendId") == None) {
Results.Redirect("/")
} else {
val userprofiles: UserProfile = null
val userprofileId = request.session.get("userId").get.toLong // userProfileId
val userprofile = UserProfile.findUserByAccountId(userprofileId).get
println(userprofile)
myFriendForm.bindFromRequest.fold(
errors => BadRequest(views.html.myFriend(errors, userprofile, myfriend, myfrnd)),
myFriend => {
println("errors")
val myFriendOpt = UserProfile.myFriend(userprofile.id.get)
println(myFriendOpt)
myFriendOpt match {
case None =>
}
Results.Redirect("/myFriend")
}
)
}
}
And this is Routes:
POST /createMyFriend controllers.Application.listMyFriend
GET /allFriends controllers.Application.listAllFriends(userId:Long)