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.


-------------------------------------
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 framework http://liftweb.net
Beginning Scala http://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
-~----------~----~----~----~------~----~------~--~---

Reply via email to