Hello! I modified those two lines of code this morning :
"local" -> SHtml.selectObj(teamOptions, Empty, (team:Team) => {localTeam = team; println("localTeam: " + team)}), "visitor" -> SHtml.selectObj(teamOptions, Empty, (team:Team) => {visitorTeam = team; println("visitorTeam: " + team)}), I obtained the result : localTeam: com.footchbol.model.Team= {teamname=bonjour,teamdescription=bonjour,city=bonjour,id=1} localTeam: com.footchbol.model.Team={teamname=au revoir,teamdescription=au revoir ,city=au revoir,id=2} in my output. Only the first anonymous submit function is used. Strange! Thank you for your help messieurs :) On Aug 31, 11:59 pm, David Pollak <feeder.of.the.be...@gmail.com> wrote: > On Mon, Aug 31, 2009 at 2:53 PM, Naftoli Gugenheim > <naftoli...@gmail.com>wrote: > > > > > I think the problem is that since visitorTeam hasn't been saved, its id is > > -1 or 0, so assigning it is meaningless. > > Either save it first, or mix in LongMappedForeignMapper in addition to > > LongMappedForeignKey on the team field. The next time I commit G-d willing > > you'll be able to write extends LongMappedMapper instead of > > LongMappedForeignKey. If that doesn't work it's a bug so please let me know. > > I don't think that's the problem. visitorTeam is being assigned (via the > selectObj callback) before the submit function is being invoked. If his > code was: > > def create(xhtml:NodeSeq):NodeSeq = { > val teams = Team.findAll > var localTeam:Team = null > var visitorTeam:Team = null > var teamOptions = teams.map(team => (team, > team.teamName.is<http://team.teamname.is/> > )) > > def submit () { > val aMatch = Match.create.local(localTeam). > visitor > (visitorTeam) > aMatch.save > } > > bind("m", xhtml, > "local" -> SHtml.selectObj(teamOptions, Empty, > (team:Team) => localTeam = team), > "visitor" -> SHtml.selectObj(teamOptions, Empty, > (team:Team) => visitorTeam = team), > "submit" -> SHtml.submit("Submit", submit)) > } > > } > > It would be the same. visitorTeam is being assigned to somethingin > teamOptions which is pulled from the RDBMS. > > > > > > > > > ------------------------------------- > > David Pollak<feeder.of.the.be...@gmail.com> wrote: > > > On Mon, Aug 31, 2009 at 2:16 PM, xabi <xavier.ta...@gmail.com> wrote: > > > > Hello! > > > > I've got a problem using SHtml.select and SHtml.selectObj. In my > > > little application. > > > > def create(xhtml:NodeSeq):NodeSeq = { > > > val teams = Team.findAll > > > var localTeam:Team = Team.create > > > var visitorTeam:Team = Team.create > > > var teamOptions = teams.map(team => (team, team.teamName.is)) > > > > def submit () { > > > val aMatch = Match.create.local(localTeam).visitor > > > (visitorTeam) > > > aMatch.save > > > } > > > > bind("m", xhtml, > > > "local" -> SHtml.selectObj(teamOptions, Empty, > > > (team:Team) => localTeam = team), > > > "visitor" -> SHtml.selectObj(teamOptions, Empty, > > > (team:Team) => visitorTeam = team), > > > "submit" -> SHtml.submit("Submit", submit)) > > > } > > > } > > > > When i submit this form, i create a Match mapper object where i set my > > > localTeam and my visitorTeam but the visitorTeam is never the one i've > > > just chosen in my select. > > > > What is my error? > > > No clue. Your code looks reasonable. Just for kicks, change the "visitor" > > bind to: > > > "visitor" -> SHtml.selectObj(teamOptions, Empty, (team:Team) => { > > visitorTeam = team; println("Set visitor to "+team)}), > > > And see if the right or wrong thing gets printed. > > > -- > > Lift, the simply functional web frameworkhttp://liftweb.net > > Beginning Scalahttp://www.apress.com/book/view/1430219890 > > Follow me:http://twitter.com/dpp > > Git some:http://github.com/dpp > > -- > Lift, the simply functional web frameworkhttp://liftweb.net > Beginning Scalahttp://www.apress.com/book/view/1430219890 > Follow me:http://twitter.com/dpp > Git some:http://github.com/dpp --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---