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)
>   }
>
> >


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