In your bind, you don't capture the nodes inside games:show, so the  
inner bind is binding the same nodes as the outer bind.

Change:

bind("games", html,
      "show" -> gameMap.values.toList.flatMap ....

to:

bind("games", html,
      "show" -> { (html: NodeSeq) => gameMap.values.toList.flatMap ...


Here is a working version: http://github.com/Dridus/rickr-lift-test

-Ross

On Oct 6, 2009, at 3:28 PM, Rick R wrote:

> My clipboard seems to have broken, so I'm attaching the index.html
>
>
> On Tue, Oct 6, 2009 at 2:57 PM, Ross Mellgren <dri...@gmail.com>  
> wrote:
> I'd have to see your revised template, since I don't see games:show  
> there, but this error indicates that you're not within a bind --  
> usually because you're not in a snippet when you think you are, or  
> when you're using a bound prefix inside some other bind. What does  
> your template look like?
>
> -Ross
>
>
>
> On Oct 6, 2009, at 2:47 PM, Rick R wrote:
>
>> Actually.. I'm running into a similar problem, this time it is  
>> dispatching correctly, but failing when rendering games.show.
>>
>> XML Parsing Error: prefix not bound to a namespace
>> Location: http://localhost:8080/
>> Line Number 20, Column 7:      <games:show>
>>                                              ------^
>>
>>   def dispatch = {
>>     case "list" => list
>>     case "add" => addGame
>>   }
>>
>>   def list(html: NodeSeq) : NodeSeq =
>>     bind("games", html,
>>            "show" -> gameMap.values.toList.flatMap
>>             { gm => bind("game", html, "id" -> Text(gm.getId),  
>> "name" -> Text(gm.getName) ) }
>>
>>
>>
>>
>> On Tue, Oct 6, 2009 at 1:21 PM, Rick R <rick.richard...@gmail.com>  
>> wrote:
>> Geez. I knew I was overlooking something stupid. Thanks for your  
>> help.
>>
>>
>>
>> On Tue, Oct 6, 2009 at 11:49 AM, Ross Mellgren <dri...@gmail.com>  
>> wrote:
>>
>> You are using a dispatch snippet, which means the name after "." in
>> the lift tag is passed to the dispatch method of your snippet, rather
>> than using reflection to find a method with the same name. So, you
>> need to add:
>>
>> case "addGame" => addGame
>>
>> to your  def dispatch
>>
>> -Ross
>>
>> On Oct 6, 2009, at 11:19 AM, Rick R wrote:
>>
>> > I have added a mapping of game_state to the DispatchSnippet
>> > GameState. This works for game_state.list, but fails for
>> > game_state.addGame, shown below.
>> > What did I screw up this time?
>> >
>> >
>> > WARN - Snippet Failure: SnippetFailure(/ -> ParsePath(List
>> > (index),,true,false),Full(game_store.addGame),Stateful Snippet:
>> > Dispatch Not Matched)
>> >
>> >
>> >
>> > <lift:surround with="default" at="content">
>> >
>> >   <lift:game_store.list>
>> >   <div id="game_list">
>> >
>> >     <ul>
>> >       <game:list>
>> >        <li><game:id>gid</game:id> <game:name>gname</game:name></li>
>> >
>> >       </game:list>
>> >     </ul>
>> >   </div>
>> >
>> >   </lift:game_store.list>
>> >   <lift:game_store.addGame form="post">
>> >
>> >     <div>
>> >       <hr/>
>> >         <p>
>> >
>> >         Create a new game:
>> >         </p>
>> >         <p>Name
>> >
>> >         <game:nom>Name</game:nom>
>> >         </p>
>> >
>> >       <p>
>> >           <game:submit>
>> >             <button>Create</button>
>> >
>> >         </game:submit>
>> >         </p>
>> >     </div>
>> >
>> >   </lift:game_store.addGame>
>> >
>> > </lift:surround>
>> >
>> >
>> >
>> >
>> >
>> > class Boot {
>> >   def boot {
>> >     // where to search snippet
>> >
>> >     LiftRules.addToPackages("com.redlemurgames")
>> >
>> >     LiftRules.snippetDispatch.append(
>> >
>> >       Map("game_store" -> GameStore)
>> >     )
>> >
>> >
>> >     val entries = Menu(Loc("Home", List("index"), "Home")) :: Nil
>> >
>> >     LiftRules.setSiteMap(SiteMap(entries:_*))
>> >
>> >
>> >   }
>> >
>> >
>> > object GameStore extends DispatchSnippet {
>> >
>> >   private val gameMap = new HashMap[String, Game]
>> >
>> >
>> >   def dispatch = {
>> >     case "list" => list
>> >
>> >   }
>> >
>> >   def list(html: NodeSeq) : NodeSeq =
>> >
>> >     bind("game", html,
>> >              "list" -> gameMap.values.toList.flatMap
>> >
>> >             { gm => bind("game", html, "id" -> Text(gm.getId),
>> > "name" -> Text(gm.getName) ) }
>> >
>> >         )
>> >
>> >
>> >   def addGame(form: NodeSeq) : NodeSeq = {
>> >
>> >     val id = randomString(12)
>> >     var gname : String = ""
>> >
>> >
>> >
>> >     def checkAndSave(): Unit =  if (gname.isEmpty)
>> >
>> >                                    {  S.error("String cannot be
>> > empty") ; S.mapSnippet("game_store.add", doBind) }
>> >
>> >                                    {  val ngame = new Game(id,
>> > gname, new HashSet[(String, Actor)]);
>> >
>> >                                       gameMap += id -> ngame;
>> >                                       ngame ! Init();
>> >
>> >                                       S.notice("Added "+
>> > ngame.getName) }
>> >
>> >
>> >
>> >     def doBind(form: NodeSeq) : NodeSeq = {
>> >
>> >       println("doBind was called")
>> >       bind("game", form,
>> >
>> >            "nom" -> text(gname, gname = _),
>> >
>> >            "submit" -> submit("New", checkAndSave))
>> >
>> >     }
>> >     doBind(form)
>> >   }
>> >
>> > >
>>
>>
>> >>
>>
>>
>
>
> <index.html>


--~--~---------~--~----~------------~-------~--~----~
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